Class: LastFM::Buylink
Instance Attribute Summary collapse
-
#is_search ⇒ Boolean
The current value of is_search.
-
#link ⇒ String
The current value of link.
-
#price ⇒ Hash
The current value of price.
-
#supplier ⇒ Hash
The current value of supplier.
-
#type ⇒ Symbol
whether the link is for a physical purchase, or a download.
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_search ⇒ Boolean
Returns the current value of is_search.
8 9 10 |
# File 'lib/lastfm/buylink.rb', line 8 def is_search @is_search end |
#link ⇒ String
Returns the current value of link.
8 9 10 |
# File 'lib/lastfm/buylink.rb', line 8 def link @link end |
#price ⇒ Hash
Returns the current value of price.
8 9 10 |
# File 'lib/lastfm/buylink.rb', line 8 def price @price end |
#supplier ⇒ Hash
Returns the current value of supplier.
8 9 10 |
# File 'lib/lastfm/buylink.rb', line 8 def supplier @supplier end |
#type ⇒ Symbol
whether the link is for a physical purchase, or a download
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 |