Class: EZTV::Episode

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

Constant Summary collapse

SE_FORMAT =
/S(\d{1,2})E(\d{1,2})/
X_FORMAT =
/(\d{1,2})x(\d{1,2})/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(episode_node) ⇒ Episode

Returns a new instance of Episode.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/eztv.rb', line 70

def initialize(episode_node)
  inner_text = episode_node.css('td.forum_thread_post a.epinfo').first.inner_text
  season_episode_match_data = inner_text.match(SE_FORMAT) || inner_text.match(X_FORMAT)

  @season = season_episode_match_data[1].to_i
  @episode_number = season_episode_match_data[2].to_i

  links_data = episode_node.css('td.forum_thread_post')[2]

  @magnet_link = links_data.css('a.magnet').first.attributes['href'].value

  @links = links_data.css('a')[2..-1].map do |a_element|
    a_element['href']
  end
end

Instance Attribute Details

#episode_numberObject

Returns the value of attribute episode_number.



68
69
70
# File 'lib/eztv.rb', line 68

def episode_number
  @episode_number
end

Returns the value of attribute links.



68
69
70
# File 'lib/eztv.rb', line 68

def links
  @links
end

Returns the value of attribute magnet_link.



68
69
70
# File 'lib/eztv.rb', line 68

def magnet_link
  @magnet_link
end

#seasonObject

Returns the value of attribute season.



68
69
70
# File 'lib/eztv.rb', line 68

def season
  @season
end

Instance Method Details

#s01e01_formatObject



86
87
88
# File 'lib/eztv.rb', line 86

def s01e01_format
  @s01e01_format ||= "S" + season.to_s.rjust(2,'0') + "E" + episode_number.to_s.rjust(2,'0')
end