Method: LastFM::Buylink#update_from_node

Defined in:
lib/lastfm/buylink.rb

#update_from_node(node) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/lastfm/buylink.rb', line 10

def update_from_node(node)
  case node.name.to_sym
    when :supplierName
      self.supplier ||= {}
      self.supplier[:name] = node.content
    when :supplierIcon
      self.supplier ||= {}
      self.supplier[:icon] = node.content
    when :price # nested price & currency
      node.find('*').each{|child| self.update_from_node(child)}
    when :amount
      self.price ||= {}
      self.price[:amount] = node.content.to_f
    when :currency
      self.price ||= {}
      self.price[:currency] = node.content
    when :buyLink
      self.link = node.content
    when :isSearch
      self.is_search = (node.content == '1')
  end
end