Class: TVdb::Serie

Inherits:
Element
  • Object
show all
Defined in:
lib/tvdb/serie.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ Serie

Returns a new instance of Serie.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/tvdb/serie.rb', line 5

def initialize(xml)
  doc = Hpricot(xml)
  
  super(doc, 'series') do |atts|
    # Turn into arrays
    atts["actors"] = atts["actors"].split('|').select{|a| !a.nil? && !a.empty?} if atts["actors"] && atts["actors"].is_a?(String) && !atts["actors"].empty?
    genres = atts.delete("genre")
    atts["genres"] = genres.split('|').select{|a| !a.nil? && !a.empty?} if genres && genres.is_a?(String) && !genres.empty?

    atts["poster"] = BANNER_URL % atts["poster"] unless atts["poster"].nil?
  end
  
  @episodes = doc.search('episode').map{|exml| Element.new(exml)}
end

Instance Attribute Details

#episodesObject

Returns the value of attribute episodes.



3
4
5
# File 'lib/tvdb/serie.rb', line 3

def episodes
  @episodes
end