Class: Bierdopje::Subtitle

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

Returns a new instance of Subtitle.



5
6
7
8
9
10
11
12
13
# File 'lib/bierdopje/subtitle.rb', line 5

def initialize doc
  attributes = {
    :file_name => doc.at_xpath('filename').content,
    :file_size => doc.at_xpath('filesize').content,
    :uploaded_at => doc.at_xpath('pubdate').content,
    :link => doc.at_xpath('downloadlink').content
  }
  super attributes
end

Instance Attribute Details

#file_nameObject

Returns the value of attribute file_name.



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

def file_name
  @file_name
end

#file_sizeObject

Returns the value of attribute file_size.



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

def file_size
  @file_size
end

Returns the value of attribute link.



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

def link
  @link
end

#uploaded_atObject

Returns the value of attribute uploaded_at.



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

def uploaded_at
  @uploaded_at
end

Class Method Details

.find(show_id, season_number, episode_number, language = :nl) ⇒ Object

Retrieve a Subtitle based on Show id, season number and episode number. You can pass the language as an option. This either has to be :nl (default) or :en.



19
20
21
22
23
24
# File 'lib/bierdopje/subtitle.rb', line 19

def find show_id, season_number, episode_number, language=:nl
  response = fetch "GetAllSubsFor/#{show_id}/#{season_number}/#{episode_number}/#{language}"
  response.xpath('results/result').collect do |result|
    Subtitle.new(result)
  end
end