Class: EZTV::Episode
- Inherits:
-
Object
- Object
- EZTV::Episode
- 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
-
#episode_number ⇒ Object
Returns the value of attribute episode_number.
-
#links ⇒ Object
Returns the value of attribute links.
-
#magnet_link ⇒ Object
Returns the value of attribute magnet_link.
-
#season ⇒ Object
Returns the value of attribute season.
Instance Method Summary collapse
-
#initialize(episode_node) ⇒ Episode
constructor
A new instance of Episode.
- #s01e01_format ⇒ Object
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_number ⇒ Object
Returns the value of attribute episode_number.
68 69 70 |
# File 'lib/eztv.rb', line 68 def episode_number @episode_number end |
#links ⇒ Object
Returns the value of attribute links.
68 69 70 |
# File 'lib/eztv.rb', line 68 def links @links end |
#magnet_link ⇒ Object
Returns the value of attribute magnet_link.
68 69 70 |
# File 'lib/eztv.rb', line 68 def magnet_link @magnet_link end |
#season ⇒ Object
Returns the value of attribute season.
68 69 70 |
# File 'lib/eztv.rb', line 68 def season @season end |
Instance Method Details
#s01e01_format ⇒ Object
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 |