Class: Bierdopje::Show
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#tvdb_id ⇒ Object
Returns the value of attribute tvdb_id.
Class Method Summary collapse
-
.find(id) ⇒ Object
Retrieve a Show based on it’s id.
-
.find_by_name(name) ⇒ Object
Retrieve a Show based on it’s exact name.
-
.find_by_tvdb_id(id) ⇒ Object
Retrieve a Show based on it’s thetvdb.com id.
-
.search(query) ⇒ Object
Searches for Shows based on it’s name.
Instance Method Summary collapse
-
#episodes(season = nil) ⇒ Object
Retrieve Episodes that belong to this Show.
-
#initialize(doc) ⇒ Show
constructor
A new instance of Show.
-
#subtitles(season, language = :nl) ⇒ Object
Retrieve all Subtitles for the given season for this Show.
Methods inherited from Base
Constructor Details
#initialize(doc) ⇒ Show
Returns a new instance of Show.
5 6 7 8 9 10 11 12 |
# File 'lib/bierdopje/show.rb', line 5 def initialize doc attributes = { :id => doc.at_xpath('showid').content, :tvdb_id => doc.at_xpath('tvdbid').content, :name => doc.at_xpath('showname').content } super attributes end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/bierdopje/show.rb', line 3 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/bierdopje/show.rb', line 3 def name @name end |
#tvdb_id ⇒ Object
Returns the value of attribute tvdb_id.
3 4 5 |
# File 'lib/bierdopje/show.rb', line 3 def tvdb_id @tvdb_id end |
Class Method Details
.find(id) ⇒ Object
Retrieve a Show based on it’s id.
37 38 39 40 |
# File 'lib/bierdopje/show.rb', line 37 def find id response = fetch "GetShowById/#{id}" Show.new response end |
.find_by_name(name) ⇒ Object
Retrieve a Show based on it’s exact name.
49 50 51 52 |
# File 'lib/bierdopje/show.rb', line 49 def find_by_name name response = fetch "GetShowByName/#{name}" Show.new response end |
Instance Method Details
#episodes(season = nil) ⇒ Object
Retrieve Episodes that belong to this Show.
15 16 17 18 19 20 21 22 |
# File 'lib/bierdopje/show.rb', line 15 def episodes season=nil path = season ? "GetEpisodesForSeason/#{id}/#{season}" : "GetAllEpisodesForShow/#{id}" response = fetch path response.xpath('results/result').collect do |result| Episode.new(result) end end |
#subtitles(season, language = :nl) ⇒ Object
Retrieve all Subtitles for the given season for this Show. The season number is a required parameter. You can pass the language as an option. This either has to be :nl
(default) or :en
.
28 29 30 31 32 33 |
# File 'lib/bierdopje/show.rb', line 28 def subtitles season, language=:nl response = fetch "GetSubsForSeason/#{id}/#{season}/#{language}" response.xpath('results/result').collect do |result| Subtitle.new(result) end end |