Class: LastFM::Album

Inherits:
Struct
  • Object
show all
Defined in:
lib/lastfm/album.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

#artistLastFM::Artist, String

Returns the current value of artist.

Returns:



16
17
18
# File 'lib/lastfm/album.rb', line 16

def artist
  @artist
end

#idFixnum

Returns the current value of id.

Returns:

  • (Fixnum)

    the current value of id



16
17
18
# File 'lib/lastfm/album.rb', line 16

def id
  @id
end

#imagesHash

Returns the current value of images.

Returns:

  • (Hash)

    the current value of images



16
17
18
# File 'lib/lastfm/album.rb', line 16

def images
  @images
end

#listenersFixnum

Returns the current value of listeners.

Returns:

  • (Fixnum)

    the current value of listeners



16
17
18
# File 'lib/lastfm/album.rb', line 16

def listeners
  @listeners
end

#mbidString

Returns the current value of mbid.

Returns:

  • (String)

    the current value of mbid



16
17
18
# File 'lib/lastfm/album.rb', line 16

def mbid
  @mbid
end

#nameString

Returns the current value of name.

Returns:

  • (String)

    the current value of name



16
17
18
# File 'lib/lastfm/album.rb', line 16

def name
  @name
end

#playcountFixnum

Returns the current value of playcount.

Returns:

  • (Fixnum)

    the current value of playcount



16
17
18
# File 'lib/lastfm/album.rb', line 16

def playcount
  @playcount
end

#release_dateTime

Returns the current value of release_date.

Returns:

  • (Time)

    the current value of release_date



16
17
18
# File 'lib/lastfm/album.rb', line 16

def release_date
  @release_date
end

#streamableBoolean

Returns the current value of streamable.

Returns:

  • (Boolean)

    the current value of streamable



16
17
18
# File 'lib/lastfm/album.rb', line 16

def streamable
  @streamable
end

#tagsArray<LastFM::Tag>

Returns the current value of tags.

Returns:



16
17
18
# File 'lib/lastfm/album.rb', line 16

def tags
  @tags
end

#tracksArray<LastFM::Track>

Returns the current value of tracks.

Returns:



16
17
18
# File 'lib/lastfm/album.rb', line 16

def tracks
  @tracks
end

#urlString

Returns the current value of url.

Returns:

  • (String)

    the current value of url



16
17
18
# File 'lib/lastfm/album.rb', line 16

def url
  @url
end

#wikiLastFM::Wiki

Returns the current value of wiki.

Returns:



16
17
18
# File 'lib/lastfm/album.rb', line 16

def wiki
  @wiki
end

Instance Method Details

#update_from_node(node) ⇒ Object



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
46
47
48
49
50
51
52
# File 'lib/lastfm/album.rb', line 18

def update_from_node(node)
  case node.name.to_sym
    when :name, :title
      self.name = node.content
    when :artist
      self.artist = (node.find('*').count == 0) ? node.content : LastFM::Artist.from_xml(node)
    when :id
      self.id = node.content.to_i
    when :mbid
      self.mbid = node.content
    when :url
      self.url = node.content
    when :releasedate
      self.release_date = Time.parse(node.content) rescue nil
    when :image
      self.images ||= {}
      self.images.merge!({node['size'].to_sym => node.content})
    when :listeners
      self.listeners = node.content.to_i
    when :playcount
      self.playcount = node.content.to_i
    when :streamable
      self.streamable = (node.content == '1')
    when :tracks
      self.tracks = node.find('track').map do |track|
        LastFM::Track.from_xml(track, :album => self.name, :position => track['rank'].to_i)
      end
    when :toptags
      self.tags = node.find('tag').map do |tag|
        LastFM::Tag.from_xml(tag)
      end
    when :wiki
      self.wiki = LastFM::Wiki.from_xml(node)
  end
end