Class: LastFM::Buylink

Inherits:
Struct
  • Object
show all
Defined in:
lib/lastfm/buylink.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Struct

from_xml, inherited, #initialize, package, #to_json

Constructor Details

This class inherits a constructor from LastFM::Struct

Instance Attribute Details

#is_searchBoolean

Returns the current value of is_search.

Returns:

  • (Boolean)

    the current value of is_search


8
9
10
# File 'lib/lastfm/buylink.rb', line 8

def is_search
  @is_search
end

Returns the current value of link.

Returns:

  • (String)

    the current value of link


8
9
10
# File 'lib/lastfm/buylink.rb', line 8

def link
  @link
end

#priceHash

Returns the current value of price.

Returns:

  • (Hash)

    the current value of price


8
9
10
# File 'lib/lastfm/buylink.rb', line 8

def price
  @price
end

#supplierHash

Returns the current value of supplier.

Returns:

  • (Hash)

    the current value of supplier


8
9
10
# File 'lib/lastfm/buylink.rb', line 8

def supplier
  @supplier
end

#typeSymbol

whether the link is for a physical purchase, or a download

Returns:

  • (Symbol)

    the current value of type


8
9
10
# File 'lib/lastfm/buylink.rb', line 8

def type
  @type
end

Instance Method Details

#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