Class: Tvrage::Tvshow
- Inherits:
-
Object
- Object
- Tvrage::Tvshow
- Defined in:
- lib/tvrage/tvshow.rb
Instance Attribute Summary collapse
-
#air_day ⇒ Object
Returns the value of attribute air_day.
-
#air_time ⇒ Object
Returns the value of attribute air_time.
-
#classification ⇒ Object
Returns the value of attribute classification.
-
#country ⇒ Object
Returns the value of attribute country.
-
#ended ⇒ Object
Returns the value of attribute ended.
-
#episodes ⇒ Object
Returns the value of attribute episodes.
-
#genres ⇒ Object
Returns the value of attribute genres.
-
#id ⇒ Object
Returns the value of attribute id.
-
#image ⇒ Object
Returns the value of attribute image.
-
#link ⇒ Object
Returns the value of attribute link.
-
#name ⇒ Object
Returns the value of attribute name.
-
#network ⇒ Object
Returns the value of attribute network.
-
#runtime ⇒ Object
Returns the value of attribute runtime.
-
#season_count ⇒ Object
Returns the value of attribute season_count.
-
#seasons ⇒ Object
Returns the value of attribute seasons.
-
#started ⇒ Object
Returns the value of attribute started.
-
#status ⇒ Object
Returns the value of attribute status.
-
#timezone ⇒ Object
Returns the value of attribute timezone.
Instance Method Summary collapse
-
#initialize(data) ⇒ Tvshow
constructor
A new instance of Tvshow.
Constructor Details
#initialize(data) ⇒ Tvshow
Returns a new instance of Tvshow.
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 42 43 44 |
# File 'lib/tvrage/tvshow.rb', line 7 def initialize(data) @id = data.xpath('showid').text.to_i @name = data.xpath('name').text @season_count = data.xpath('totalseasons').text.to_i @image = data.xpath('image').text @country = data.xpath('origin_country').text @link = data.xpath('link').text @status = data.xpath('status').text @classification = data.xpath('classification').text @runtime = data.xpath('runtime').text.to_i @network = data.xpath('network').text @air_day = data.xpath('air_day').text @timezone = data.xpath('timezone').text @link = data.xpath('showlink').text begin @air_time = Time.parse(data.xpath('airtime').text) if !data.xpath('airtime').text.empty? rescue Exception => e # invalid air time end @genres = data.xpath('genres/genre').map { |g| g.text } if data.xpath('genres/genre').length > 0 @genres.reject! { |g| g.empty? } unless @genres.nil? begin @started = Date.parse(data.xpath('started').text) if !data.xpath('started').text.empty? rescue Exception => e # invalid start date end begin @ended = Date.parse(data.xpath('ended').text) if !data.xpath('ended').text.empty? rescue Exception => e # invalid end date end @episodes = data.xpath('Episodelist//Season/episode').map { |e| Episode.new(e, e.parent['no']) } end |
Instance Attribute Details
#air_day ⇒ Object
Returns the value of attribute air_day.
5 6 7 |
# File 'lib/tvrage/tvshow.rb', line 5 def air_day @air_day end |
#air_time ⇒ Object
Returns the value of attribute air_time.
5 6 7 |
# File 'lib/tvrage/tvshow.rb', line 5 def air_time @air_time end |
#classification ⇒ Object
Returns the value of attribute classification.
5 6 7 |
# File 'lib/tvrage/tvshow.rb', line 5 def classification @classification end |
#country ⇒ Object
Returns the value of attribute country.
5 6 7 |
# File 'lib/tvrage/tvshow.rb', line 5 def country @country end |
#ended ⇒ Object
Returns the value of attribute ended.
5 6 7 |
# File 'lib/tvrage/tvshow.rb', line 5 def ended @ended end |
#episodes ⇒ Object
Returns the value of attribute episodes.
5 6 7 |
# File 'lib/tvrage/tvshow.rb', line 5 def episodes @episodes end |
#genres ⇒ Object
Returns the value of attribute genres.
5 6 7 |
# File 'lib/tvrage/tvshow.rb', line 5 def genres @genres end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/tvrage/tvshow.rb', line 5 def id @id end |
#image ⇒ Object
Returns the value of attribute image.
5 6 7 |
# File 'lib/tvrage/tvshow.rb', line 5 def image @image end |
#link ⇒ Object
Returns the value of attribute link.
5 6 7 |
# File 'lib/tvrage/tvshow.rb', line 5 def link @link end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/tvrage/tvshow.rb', line 5 def name @name end |
#network ⇒ Object
Returns the value of attribute network.
5 6 7 |
# File 'lib/tvrage/tvshow.rb', line 5 def network @network end |
#runtime ⇒ Object
Returns the value of attribute runtime.
5 6 7 |
# File 'lib/tvrage/tvshow.rb', line 5 def runtime @runtime end |
#season_count ⇒ Object
Returns the value of attribute season_count.
5 6 7 |
# File 'lib/tvrage/tvshow.rb', line 5 def season_count @season_count end |
#seasons ⇒ Object
Returns the value of attribute seasons.
5 6 7 |
# File 'lib/tvrage/tvshow.rb', line 5 def seasons @seasons end |
#started ⇒ Object
Returns the value of attribute started.
5 6 7 |
# File 'lib/tvrage/tvshow.rb', line 5 def started @started end |
#status ⇒ Object
Returns the value of attribute status.
5 6 7 |
# File 'lib/tvrage/tvshow.rb', line 5 def status @status end |
#timezone ⇒ Object
Returns the value of attribute timezone.
5 6 7 |
# File 'lib/tvrage/tvshow.rb', line 5 def timezone @timezone end |