Class: TvDotCom::Episode

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(show, season, raw_html) ⇒ Episode

Returns a new instance of Episode.



105
106
107
108
109
# File 'lib/tv_dot_com.rb', line 105

def initialize(show, season, raw_html)
  @show = show
  @season = season
  @raw_html = raw_html
end

Instance Attribute Details

#seasonObject (readonly)

Returns the value of attribute season.



103
104
105
# File 'lib/tv_dot_com.rb', line 103

def season
  @season
end

#showObject (readonly)

Returns the value of attribute show.



103
104
105
# File 'lib/tv_dot_com.rb', line 103

def show
  @show
end

Instance Method Details

#first_airedObject



131
132
133
# File 'lib/tv_dot_com.rb', line 131

def first_aired
  Date.parse((@raw_html/"td[@class='ta-c']:empty").inner_html.match(/\d+\/\d+\/\d+/)[0])
end

#numberObject



115
116
117
# File 'lib/tv_dot_com.rb', line 115

def number
  (@raw_html/"td[@class='first f-bold ta-c']").inner_html.match(/\s*(\S*)\s*/)[1]
end

#production_numberObject



119
120
121
# File 'lib/tv_dot_com.rb', line 119

def production_number
  (@raw_html/"td[@class='f-666 f-11 ta-c']").inner_html.match(/\s*(\S*)\s*/)[1]      
end

#season_numberObject



123
124
125
# File 'lib/tv_dot_com.rb', line 123

def season_number
  @season.number
end

#titleObject



111
112
113
# File 'lib/tv_dot_com.rb', line 111

def title
  title_link_elem.inner_html
end


135
136
137
# File 'lib/tv_dot_com.rb', line 135

def title_link_elem
  (@raw_html/"a[@href*=summary]").first
end

#urlObject



127
128
129
# File 'lib/tv_dot_com.rb', line 127

def url
  title_link_elem.attributes["href"]
end