Class: P3::Tvdb::Episode
- Inherits:
-
Object
- Object
- P3::Tvdb::Episode
- Defined in:
- lib/p3-tvdb/episode.rb
Instance Attribute Summary collapse
-
#air_date ⇒ Object
Returns the value of attribute air_date.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#director ⇒ Object
Returns the value of attribute director.
-
#guest_stars ⇒ Object
Returns the value of attribute guest_stars.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#number ⇒ Object
Returns the value of attribute number.
-
#overview ⇒ Object
Returns the value of attribute overview.
-
#rating ⇒ Object
Returns the value of attribute rating.
-
#rating_count ⇒ Object
Returns the value of attribute rating_count.
-
#season_number ⇒ Object
Returns the value of attribute season_number.
-
#thumb ⇒ Object
Returns the value of attribute thumb.
-
#writer ⇒ Object
Returns the value of attribute writer.
Instance Method Summary collapse
-
#initialize(client, options = {}) ⇒ Episode
constructor
A new instance of Episode.
- #series ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(client, options = {}) ⇒ Episode
Returns a new instance of Episode.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/p3-tvdb/episode.rb', line 7 def initialize(client, ={}) @client = client @id = ["id"] @season_number = ["SeasonNumber"].to_i @number = ["EpisodeNumber"].to_i @name = ["EpisodeName"] @overview = ["Overview"] @thumb = "http://thetvdb.com/banners/" + ["filename"] if ["filename"].to_s != "" @director = ["Director"] @writer = ["Writer"] @series_id = ["seriesid"] @rating_count = ["RatingCount"] if ["GuestStars"] @guest_stars = ["GuestStars"][1..-1].split("|") else @guest_stars = [] end if ["Rating"] && ["Rating"].size > 0 @rating = ["Rating"].to_f else @rating = 0 end if ["RatingCount"] && ["RatingCount"].size > 0 @rating_count = ["RatingCount"].to_f else @rating_count = 0 end begin @air_date = Date.parse(["FirstAired"]) rescue end end |
Instance Attribute Details
#air_date ⇒ Object
Returns the value of attribute air_date.
5 6 7 |
# File 'lib/p3-tvdb/episode.rb', line 5 def air_date @air_date end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
4 5 6 |
# File 'lib/p3-tvdb/episode.rb', line 4 def client @client end |
#director ⇒ Object
Returns the value of attribute director.
5 6 7 |
# File 'lib/p3-tvdb/episode.rb', line 5 def director @director end |
#guest_stars ⇒ Object
Returns the value of attribute guest_stars.
5 6 7 |
# File 'lib/p3-tvdb/episode.rb', line 5 def guest_stars @guest_stars end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/p3-tvdb/episode.rb', line 5 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/p3-tvdb/episode.rb', line 5 def name @name end |
#number ⇒ Object
Returns the value of attribute number.
5 6 7 |
# File 'lib/p3-tvdb/episode.rb', line 5 def number @number end |
#overview ⇒ Object
Returns the value of attribute overview.
5 6 7 |
# File 'lib/p3-tvdb/episode.rb', line 5 def overview @overview end |
#rating ⇒ Object
Returns the value of attribute rating.
5 6 7 |
# File 'lib/p3-tvdb/episode.rb', line 5 def @rating end |
#rating_count ⇒ Object
Returns the value of attribute rating_count.
5 6 7 |
# File 'lib/p3-tvdb/episode.rb', line 5 def @rating_count end |
#season_number ⇒ Object
Returns the value of attribute season_number.
5 6 7 |
# File 'lib/p3-tvdb/episode.rb', line 5 def season_number @season_number end |
#thumb ⇒ Object
Returns the value of attribute thumb.
5 6 7 |
# File 'lib/p3-tvdb/episode.rb', line 5 def thumb @thumb end |
#writer ⇒ Object
Returns the value of attribute writer.
5 6 7 |
# File 'lib/p3-tvdb/episode.rb', line 5 def writer @writer end |
Instance Method Details
#series ⇒ Object
43 44 45 |
# File 'lib/p3-tvdb/episode.rb', line 43 def series client.get_series_by_id(@series_id) end |
#to_h ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/p3-tvdb/episode.rb', line 47 def to_h hash = {} self.instance_variables.each do | var | #turn episode object into hash v = self.instance_variable_get( var ) hash[ var.to_s.gsub('@','').to_sym ] = v end hash.delete(:client) return hash end |