Class: LastFM::Artist

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Struct

from_xml, #initialize, package

Constructor Details

This class inherits a constructor from LastFM::Struct

Instance Attribute Details

#imagesHash

Returns the current value of images.

Returns:

  • (Hash)

    the current value of images



13
14
15
# File 'lib/lastfm/artist.rb', line 13

def images
  @images
end

#listenersFixnum

Returns the current value of listeners.

Returns:

  • (Fixnum)

    the current value of listeners



13
14
15
# File 'lib/lastfm/artist.rb', line 13

def listeners
  @listeners
end

#mbidString

Returns the current value of mbid.

Returns:

  • (String)

    the current value of mbid



13
14
15
# File 'lib/lastfm/artist.rb', line 13

def mbid
  @mbid
end

#nameString

Returns the current value of name.

Returns:

  • (String)

    the current value of name



13
14
15
# File 'lib/lastfm/artist.rb', line 13

def name
  @name
end

#playcountFixnum

Returns the current value of playcount.

Returns:

  • (Fixnum)

    the current value of playcount



13
14
15
# File 'lib/lastfm/artist.rb', line 13

def playcount
  @playcount
end

#similarArray

Returns the current value of similar.

Returns:

  • (Array)

    the current value of similar



13
14
15
# File 'lib/lastfm/artist.rb', line 13

def similar
  @similar
end

#streamableBoolean

Returns the current value of streamable.

Returns:

  • (Boolean)

    the current value of streamable



13
14
15
# File 'lib/lastfm/artist.rb', line 13

def streamable
  @streamable
end

#tagsArray

Returns the current value of tags.

Returns:

  • (Array)

    the current value of tags



13
14
15
# File 'lib/lastfm/artist.rb', line 13

def tags
  @tags
end

#urlString

Returns the current value of url.

Returns:

  • (String)

    the current value of url



13
14
15
# File 'lib/lastfm/artist.rb', line 13

def url
  @url
end

#wikiLastFM::Wiki

Returns the current value of wiki.

Returns:



13
14
15
# File 'lib/lastfm/artist.rb', line 13

def wiki
  @wiki
end

Instance Method Details

#update_from_node(node) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/lastfm/artist.rb', line 15

def update_from_node(node)
  case node.name.to_sym
    when :name
      self.name = node.content
    when :mbid
      self.mbid = node.content
    when :url
      self.url = node.content
    when :image
      self.images ||= {}
      self.images.merge!({node['size'].to_sym => node.content})
    when :streamable
      self.streamable = (node.content == '1')
    when :listeners
      self.listeners = node.content.to_i
    when :playcount
      self.playcount = node.content.to_i
    when :stats # nested listeners and playcount

      node.find('*').each{|child| self.update_from_node(child)}
    when :similar
      self.similar = node.find('artist').map do |artist|
        LastFM::Artist.from_xml(artist)
      end
    when :tags
      self.tags = node.find('tag').map do |tag|
        LastFM::Tag.from_xml(tag)
      end
    when :bio
      self.wiki = LastFM::Wiki.from_xml(node)
  end
end