Class: Tvrage::Episode

Inherits:
Object
  • Object
show all
Defined in:
lib/tvrage/episode.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, season_number = 0) ⇒ Episode

Returns a new instance of Episode.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/tvrage/episode.rb', line 7

def initialize(data, season_number = 0)
  @season = season_number.to_i
  @number = data.xpath('seasonnum').text.to_i
  @product_number = data.xpath('prodnum').text
  @link = data.xpath('link').text
  @title = data.xpath('title').text
  @screencap = data.xpath('screencap').text if !data.xpath('screencap').text.empty?
  
  begin
    @air_date = Date.parse(data.xpath('airdate').text) if !data.xpath('airdate').text.empty?
  rescue Exception => e
    # air date is invalid
  end
  
end

Instance Attribute Details

#air_dateObject

Returns the value of attribute air_date.



5
6
7
# File 'lib/tvrage/episode.rb', line 5

def air_date
  @air_date
end

Returns the value of attribute link.



5
6
7
# File 'lib/tvrage/episode.rb', line 5

def link
  @link
end

#numberObject

Returns the value of attribute number.



5
6
7
# File 'lib/tvrage/episode.rb', line 5

def number
  @number
end

#product_numberObject

Returns the value of attribute product_number.



5
6
7
# File 'lib/tvrage/episode.rb', line 5

def product_number
  @product_number
end

#screencapObject

Returns the value of attribute screencap.



5
6
7
# File 'lib/tvrage/episode.rb', line 5

def screencap
  @screencap
end

#seasonObject

Returns the value of attribute season.



5
6
7
# File 'lib/tvrage/episode.rb', line 5

def season
  @season
end

#titleObject

Returns the value of attribute title.



5
6
7
# File 'lib/tvrage/episode.rb', line 5

def title
  @title
end