Class: Tvdb2::Episode
- Inherits:
-
Object
- Object
- Tvdb2::Episode
- Defined in:
- lib/tvdb2/episode.rb
Overview
This class rappresent a series episode retrieved from TVDB api.
Constant Summary
- INDEX_FIELDS =
Fields returned from api endpoint
GET /series/{id}/episodes
[ :absoluteNumber, :airedEpisodeNumber, :airedSeason,:dvdEpisodeNumber, :dvdSeason, :episodeName, :firstAired, :id, :lastUpdated, :overview ]
- SHOW_FIELDS =
Other fields with INDEX_FIELDS returned from api endpoint
GET /episodes/{id}
[ :airsAfterSeason, :airsBeforeEpisode, :airsBeforeSeason, :direcotor, :directors, :dvdChapter, :dvdDiscid, :filename, :guestStars, :imdbId, :lastUpdatedBy, :productionCode, :seriesId, :showUrl, :siteRating, :siteRatingCount, :thumbAdded, :thumbAuthor, :thumbHeight, :thumbWidth, :writers ]
- FIELDS =
All possible data fields returned from api for a series.
INDEX_FIELDS + SHOW_FIELDS
Instance Attribute Summary collapse
-
#absoluteNumber ⇒ Object
readonly
Returns the value of attribute absoluteNumber.
-
#airedEpisodeNumber ⇒ Object
(also: #number)
readonly
Returns the value of attribute airedEpisodeNumber.
-
#airedSeason ⇒ Object
(also: #seasonNumber)
readonly
Returns the value of attribute airedSeason.
-
#airsAfterSeason ⇒ Object
readonly
Returns the value of attribute airsAfterSeason.
-
#airsBeforeEpisode ⇒ Object
readonly
Returns the value of attribute airsBeforeEpisode.
-
#airsBeforeSeason ⇒ Object
readonly
Returns the value of attribute airsBeforeSeason.
-
#direcotor ⇒ Object
readonly
Returns the value of attribute direcotor.
-
#directors ⇒ Object
readonly
Returns the value of attribute directors.
-
#dvdChapter ⇒ Object
readonly
Returns the value of attribute dvdChapter.
-
#dvdDiscid ⇒ Object
readonly
Returns the value of attribute dvdDiscid.
-
#dvdEpisodeNumber ⇒ Object
readonly
Returns the value of attribute dvdEpisodeNumber.
-
#dvdSeason ⇒ Object
readonly
Returns the value of attribute dvdSeason.
-
#episodeName ⇒ Object
(also: #name)
readonly
Returns the value of attribute episodeName.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#firstAired ⇒ Object
readonly
Returns the value of attribute firstAired.
-
#guestStars ⇒ Object
readonly
Returns the value of attribute guestStars.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#imdbId ⇒ Object
readonly
Returns the value of attribute imdbId.
-
#lastUpdated ⇒ Object
readonly
Returns the value of attribute lastUpdated.
-
#lastUpdatedBy ⇒ Object
readonly
Returns the value of attribute lastUpdatedBy.
-
#overview ⇒ Object
readonly
Returns the value of attribute overview.
-
#productionCode ⇒ Object
readonly
Returns the value of attribute productionCode.
-
#seriesId ⇒ Object
readonly
Returns the value of attribute seriesId.
-
#showUrl ⇒ Object
readonly
Returns the value of attribute showUrl.
-
#siteRating ⇒ Object
readonly
Returns the value of attribute siteRating.
-
#siteRatingCount ⇒ Object
readonly
Returns the value of attribute siteRatingCount.
-
#thumbAdded ⇒ Object
readonly
Returns the value of attribute thumbAdded.
-
#thumbAuthor ⇒ Object
readonly
Returns the value of attribute thumbAuthor.
-
#thumbHeight ⇒ Object
readonly
Returns the value of attribute thumbHeight.
-
#thumbWidth ⇒ Object
readonly
Returns the value of attribute thumbWidth.
-
#writers ⇒ Object
readonly
Returns the value of attribute writers.
Instance Method Summary collapse
-
#initialize(client, data = {}) ⇒ Episode
constructor
A new instance of Episode.
-
#to_h(retrieve_all_fields: false) ⇒ Hash
The episode to hash.
-
#x ⇒ String
The episode number with the “x” syntax:
"#{season_number}x#{episode_number}
(3x9)“.
Constructor Details
#initialize(client, data = {}) ⇒ Episode
The Tvdb2::Episode object may not have all fields filled because it can be
initialized from not completed data like when is build from the call
Series#episodes (GET /series/{id}/episodes
): in this case
the api call return a subset of all avaiable data for the episodes
(INDEX_FIELDS). But no warries! When you call a method to get one
SHOW_FIELDS the library automatically call the endpoint GET
/episodes/{id}
to retrieve the missing fields.
You should never need to create this object manually.
Returns a new instance of Episode
68 69 70 71 72 73 74 |
# File 'lib/tvdb2/episode.rb', line 68 def initialize(client, data = {}) @client = client FIELDS.each do |field| instance_variable_set("@#{field}", data[field.to_s]) end @completed = {@client.language => data.key?('seriesId')} end |
Instance Attribute Details
#absoluteNumber ⇒ Object (readonly)
Returns the value of attribute absoluteNumber
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def absoluteNumber @absoluteNumber end |
#airedEpisodeNumber ⇒ Object (readonly) Also known as: number
Returns the value of attribute airedEpisodeNumber
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def airedEpisodeNumber @airedEpisodeNumber end |
#airedSeason ⇒ Object (readonly) Also known as: seasonNumber
Returns the value of attribute airedSeason
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def airedSeason @airedSeason end |
#airsAfterSeason ⇒ Object (readonly)
Returns the value of attribute airsAfterSeason
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def airsAfterSeason @airsAfterSeason end |
#airsBeforeEpisode ⇒ Object (readonly)
Returns the value of attribute airsBeforeEpisode
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def airsBeforeEpisode @airsBeforeEpisode end |
#airsBeforeSeason ⇒ Object (readonly)
Returns the value of attribute airsBeforeSeason
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def airsBeforeSeason @airsBeforeSeason end |
#direcotor ⇒ Object (readonly)
Returns the value of attribute direcotor
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def direcotor @direcotor end |
#directors ⇒ Object (readonly)
Returns the value of attribute directors
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def directors @directors end |
#dvdChapter ⇒ Object (readonly)
Returns the value of attribute dvdChapter
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def dvdChapter @dvdChapter end |
#dvdDiscid ⇒ Object (readonly)
Returns the value of attribute dvdDiscid
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def dvdDiscid @dvdDiscid end |
#dvdEpisodeNumber ⇒ Object (readonly)
Returns the value of attribute dvdEpisodeNumber
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def dvdEpisodeNumber @dvdEpisodeNumber end |
#dvdSeason ⇒ Object (readonly)
Returns the value of attribute dvdSeason
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def dvdSeason @dvdSeason end |
#episodeName ⇒ Object (readonly) Also known as: name
Returns the value of attribute episodeName
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def episodeName @episodeName end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def filename @filename end |
#firstAired ⇒ Object (readonly)
Returns the value of attribute firstAired
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def firstAired @firstAired end |
#guestStars ⇒ Object (readonly)
Returns the value of attribute guestStars
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def guestStars @guestStars end |
#id ⇒ Object (readonly)
Returns the value of attribute id
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def id @id end |
#imdbId ⇒ Object (readonly)
Returns the value of attribute imdbId
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def imdbId @imdbId end |
#lastUpdated ⇒ Object (readonly)
Returns the value of attribute lastUpdated
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def lastUpdated @lastUpdated end |
#lastUpdatedBy ⇒ Object (readonly)
Returns the value of attribute lastUpdatedBy
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def lastUpdatedBy @lastUpdatedBy end |
#overview ⇒ Object (readonly)
Returns the value of attribute overview
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def overview @overview end |
#productionCode ⇒ Object (readonly)
Returns the value of attribute productionCode
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def productionCode @productionCode end |
#seriesId ⇒ Object (readonly)
Returns the value of attribute seriesId
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def seriesId @seriesId end |
#showUrl ⇒ Object (readonly)
Returns the value of attribute showUrl
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def showUrl @showUrl end |
#siteRating ⇒ Object (readonly)
Returns the value of attribute siteRating
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def siteRating @siteRating end |
#siteRatingCount ⇒ Object (readonly)
Returns the value of attribute siteRatingCount
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def siteRatingCount @siteRatingCount end |
#thumbAdded ⇒ Object (readonly)
Returns the value of attribute thumbAdded
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def thumbAdded @thumbAdded end |
#thumbAuthor ⇒ Object (readonly)
Returns the value of attribute thumbAuthor
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def thumbAuthor @thumbAuthor end |
#thumbHeight ⇒ Object (readonly)
Returns the value of attribute thumbHeight
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def thumbHeight @thumbHeight end |
#thumbWidth ⇒ Object (readonly)
Returns the value of attribute thumbWidth
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def thumbWidth @thumbWidth end |
#writers ⇒ Object (readonly)
Returns the value of attribute writers
25 26 27 |
# File 'lib/tvdb2/episode.rb', line 25 def writers @writers end |
Instance Method Details
#to_h(retrieve_all_fields: false) ⇒ Hash
Returns the episode to hash.
85 86 87 88 89 90 91 92 93 |
# File 'lib/tvdb2/episode.rb', line 85 def to_h(retrieve_all_fields: false) get_all_fields! if retrieve_all_fields hash = {} FIELDS.each do |field| hash[field.to_sym] = instance_variable_get("@#{field}") end hash[:name] = @episodeName return hash end |
#x ⇒ String
Returns the episode number with the “x” syntax:
"#{season_number}x#{episode_number}
(3x9)“.
78 79 80 |
# File 'lib/tvdb2/episode.rb', line 78 def x "#{self.airedSeason}x#{self.airedEpisodeNumber}" end |