Class: P3::Eztv::Series

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/p3-eztv.rb

Constant Summary collapse

EPISODES_XPATH =
'//*[@id="header_holder"]/table[5]'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Series

Returns a new instance of Series.



24
25
26
27
# File 'lib/p3-eztv.rb', line 24

def initialize(name)
    @name = name
    @high_def = false
end

Instance Attribute Details

#high_defObject (readonly)

Returns the value of attribute high_def.



19
20
21
# File 'lib/p3-eztv.rb', line 19

def high_def
  @high_def
end

#nameObject (readonly)

Returns the value of attribute name.



19
20
21
# File 'lib/p3-eztv.rb', line 19

def name
  @name
end

Instance Method Details

#episode(season, episode_number) ⇒ Object



42
43
44
45
46
# File 'lib/p3-eztv.rb', line 42

def episode(season, episode_number)
    episodes().find do |episode|
        episode.season == season and episode.episode_number == episode_number
    end
end

#episodesObject



38
39
40
# File 'lib/p3-eztv.rb', line 38

def episodes
    @episodes ||= EpisodeFactory.create( name, fetch_episodes() )
end

#get(s01e01_format) ⇒ Object



48
49
50
51
52
53
# File 'lib/p3-eztv.rb', line 48

def get(s01e01_format)
    season_episode_match_data = s01e01_format.match( /#{SE_FORMAT}/ )
    season  = season_episode_match_data[1].to_i
    episode_number = season_episode_match_data[2].to_i
    return episode(season, episode_number)
end

#high_def!Object



29
30
31
# File 'lib/p3-eztv.rb', line 29

def high_def!
    @high_def = true
end

#search_stringObject



33
34
35
36
# File 'lib/p3-eztv.rb', line 33

def search_string
    search =  @high_def ? "#{@name} 720p" : @name
    return URI::escape( search )
end

#season(season) ⇒ Object



55
56
57
# File 'lib/p3-eztv.rb', line 55

def season(season)
    episodes().find_all {|episode| episode.season == season }
end

#seasonsObject



59
60
61
# File 'lib/p3-eztv.rb', line 59

def seasons
    episodes().sort.group_by {|episode| episode.season }
end