Class: TVDB::Episodes

Inherits:
Object
  • Object
show all
Defined in:
lib/tvdb-rb/episodes.rb

Instance Method Summary collapse

Constructor Details

#initialize(episodes) ⇒ Episodes

Returns a new instance of Episodes.



5
6
7
# File 'lib/tvdb-rb/episodes.rb', line 5

def initialize episodes
  @episodes = episodes
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object (private)



35
36
37
38
# File 'lib/tvdb-rb/episodes.rb', line 35

def method_missing(sym, *args, &block)
  return episodes.send(sym, *args, &block) if episodes.respond_to?(sym)
  super(sym, *args, &block)
end

Instance Method Details

#allObject



9
10
11
# File 'lib/tvdb-rb/episodes.rb', line 9

def all
  episodes
end

#search_by_guest_stars(guest_stars) ⇒ Object



17
18
19
# File 'lib/tvdb-rb/episodes.rb', line 17

def search_by_guest_stars guest_stars
  Episodes.new(episodes.select{|e| e.guest_stars.include?(guest_stars) } )
end

#search_by_overview(query_string) ⇒ Object



21
22
23
# File 'lib/tvdb-rb/episodes.rb', line 21

def search_by_overview query_string
  Episodes.new(episodes.select{|e| e.overview.match(query_string) } )
end

#search_by_season_number(season_number) ⇒ Object



13
14
15
# File 'lib/tvdb-rb/episodes.rb', line 13

def search_by_season_number season_number
  Episodes.new(episodes.select{|e| e.season_number == season_number} )
end

#sort_by_ratingObject



25
26
27
# File 'lib/tvdb-rb/episodes.rb', line 25

def sort_by_rating
  episodes.sort_by{|e| e.rating }
end