Class: TVdb::Element

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/tvdb/element.rb

Direct Known Subclasses

Serie

Instance Method Summary collapse

Constructor Details

#initialize(xml, root_name = nil) {|atts| ... } ⇒ Element

Returns a new instance of Element.

Yields:

  • (atts)


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

def initialize(xml, root_name=nil)
  @root_name = root_name
  
  atts = attributes_from_xml(xml)
  
  # Downcase the keys
  atts = atts.inject({}){|options, (k,v)| options[k.downcase] = v; options}
  
  # Don't mess with Object.id
  if atts.has_key?('id')
    sid = atts.delete('id')
    atts[:tvdb_id] = sid
  end
  
  yield(atts) if block_given?
  
  super(atts)
end