Class: Yesradio::Item

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

Direct Known Subclasses

Song, Station

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element = nil) ⇒ Item

Returns a new instance of Item.



12
13
14
15
16
17
# File 'lib/item.rb', line 12

def initialize(element = nil)
  self.class.elements.each do |name, type|
    new_value = get_element_child element, name.gsub('_', '/'), type
    self.instance_variable_set("@#{name}", new_value) unless new_value.nil?
  end
end

Class Attribute Details

.elementsObject

Returns the value of attribute elements.



9
10
11
# File 'lib/item.rb', line 9

def elements
  @elements
end