Class: Bierdopje::Episode

Inherits:
Base
  • Object
show all
Defined in:
lib/bierdopje/episode.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) ⇒ Episode

Returns a new instance of Episode.



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/bierdopje/episode.rb', line 20

def initialize doc
  attributes = {
    :id => doc.at_xpath('episodeid').content,
    :season => doc.at_xpath('season').content,
    :episode => doc.at_xpath('episode').content,
    :code => doc.at_xpath('formatted').content,
    :title => doc.at_xpath('title').content,
    :summary => doc.at_xpath('summary').content,
    :air_date => doc.at_xpath('airdate').content,
    :show_name => doc.at_xpath('showlink').content.match(/^http:\/\/www\.bierdopje\.com\/shows\/(.*)$/)[1]
  }
  super attributes
end

Instance Attribute Details

#air_dateObject

Returns the value of attribute air_date.



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

def air_date
  @air_date
end

#codeObject

Returns the value of attribute code.



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

def code
  @code
end

#episodeObject

Returns the value of attribute episode.



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

def episode
  @episode
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#seasonObject

Returns the value of attribute season.



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

def season
  @season
end

#show_nameObject

Returns the value of attribute show_name.



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

def show_name
  @show_name
end

#summaryObject

Returns the value of attribute summary.



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

def summary
  @summary
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

Class Method Details

.find(id) ⇒ Object

Retrieve an Episode based on it’s id.



36
37
38
39
# File 'lib/bierdopje/episode.rb', line 36

def find id
  response = parse("GetEpisodeById/#{id}").at_xpath('bierdopje/response/results')
  Episode.new response
end

Instance Method Details

#showObject

Retrieve the Show this Episode belongs to.



6
7
8
# File 'lib/bierdopje/episode.rb', line 6

def show
  Show.find_by_name show_name
end

#subtitles(language = :nl) ⇒ Object

Retrieve all Subtitles for this Episode. You can pass the language as an option. This either has to be :nl (default) or :en.



13
14
15
16
17
18
# File 'lib/bierdopje/episode.rb', line 13

def subtitles language=:nl
  response = fetch "GetAllSubsForEpisode/#{id}/#{language}"
  response.xpath('results/result').collect do |result|
    Subtitle.new(result)
  end
end