Class: EZTV::Series
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #episode(season, episode_number) ⇒ Object
- #episodes ⇒ Object
-
#initialize(name) ⇒ Series
constructor
A new instance of Series.
- #season(season) ⇒ Object
- #seasons ⇒ Object
Constructor Details
#initialize(name) ⇒ Series
Returns a new instance of Series.
19 20 21 22 |
# File 'lib/eztv.rb', line 19 def initialize(name) @name = name = { body: {'SearchString' => @name}} end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
17 18 19 |
# File 'lib/eztv.rb', line 17 def name @name end |
Instance Method Details
#episode(season, episode_number) ⇒ Object
41 42 43 44 45 |
# File 'lib/eztv.rb', line 41 def episode(season, episode_number) episodes.find do |episode| episode.season == season and episode.episode_number == episode_number end end |
#episodes ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/eztv.rb', line 24 def episodes return @episodes if @episodes result = self.class.post('/search/',) document = Nokogiri::HTML(result) episodes = document.css('html body div#header_holder table.forum_header_border tr.forum_header_border') raise SeriesNotFoundError.new(self) if episodes.empty? episodes = episodes.reject do |episode| episode.css('img').first.attributes['title'].value.match(/Show Description about #{name}/i).nil? end @episodes = EpisodeFactory.create(episodes) end |
#season(season) ⇒ Object
47 48 49 |
# File 'lib/eztv.rb', line 47 def season(season) episodes.find_all {|episode| episode.season == season } end |
#seasons ⇒ Object
51 52 53 |
# File 'lib/eztv.rb', line 51 def seasons episodes.group_by {|episode| episode.season }.to_hash.values end |