Class: Bierdopje::Show

Inherits:
Base
  • Object
show all
Defined in:
lib/bierdopje/show.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

api_key, api_key=

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

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/bierdopje/show.rb', line 3

def id
  @id
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/bierdopje/show.rb', line 3

def name
  @name
end

#tvdb_idObject

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

.find_by_tvdb_id(id) ⇒ Object

Retrieve a Show based on it’s thetvdb.com id.



43
44
45
46
# File 'lib/bierdopje/show.rb', line 43

def find_by_tvdb_id id
  response = fetch "GetShowByTVDBID/#{id}"
  Show.new response
end

.search(query) ⇒ Object

Searches for Shows based on it’s name.



55
56
57
58
59
60
# File 'lib/bierdopje/show.rb', line 55

def search query
  response = fetch "FindShowByName/#{query}"
  response.xpath('results/result').collect do |result|
    Show.new(result)
  end
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