Class: LastFM::Track

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

#albumLastFM::Album

Returns the current value of album.

Returns:



18
19
20
# File 'lib/lastfm/track.rb', line 18

def album
  @album
end

#artistLastFM::Artist, String

Returns the current value of artist.

Returns:



18
19
20
# File 'lib/lastfm/track.rb', line 18

def artist
  @artist
end

#durationFixnum

Returns the current value of duration.

Returns:

  • (Fixnum)

    the current value of duration



18
19
20
# File 'lib/lastfm/track.rb', line 18

def duration
  @duration
end

#idFixnum

Returns the current value of id.

Returns:

  • (Fixnum)

    the current value of id



18
19
20
# File 'lib/lastfm/track.rb', line 18

def id
  @id
end

#imagesHash

Returns the current value of images.

Returns:

  • (Hash)

    the current value of images



18
19
20
# File 'lib/lastfm/track.rb', line 18

def images
  @images
end

#listenersFixnum

Returns the current value of listeners.

Returns:

  • (Fixnum)

    the current value of listeners



18
19
20
# File 'lib/lastfm/track.rb', line 18

def listeners
  @listeners
end

#mbidString

Returns the current value of mbid.

Returns:

  • (String)

    the current value of mbid



18
19
20
# File 'lib/lastfm/track.rb', line 18

def mbid
  @mbid
end

#nameString

Returns the current value of name.

Returns:

  • (String)

    the current value of name



18
19
20
# File 'lib/lastfm/track.rb', line 18

def name
  @name
end

#playcountFixnum

Returns the current value of playcount.

Returns:

  • (Fixnum)

    the current value of playcount



18
19
20
# File 'lib/lastfm/track.rb', line 18

def playcount
  @playcount
end

#positionFixnum

Returns the current value of position.

Returns:

  • (Fixnum)

    the current value of position



18
19
20
# File 'lib/lastfm/track.rb', line 18

def position
  @position
end

#streamableBoolean

Returns the current value of streamable.

Returns:

  • (Boolean)

    the current value of streamable



18
19
20
# File 'lib/lastfm/track.rb', line 18

def streamable
  @streamable
end

#streamable_fulltrackBoolean

Returns the current value of streamable_fulltrack.

Returns:

  • (Boolean)

    the current value of streamable_fulltrack



18
19
20
# File 'lib/lastfm/track.rb', line 18

def streamable_fulltrack
  @streamable_fulltrack
end

#tagsArray

Returns the current value of tags.

Returns:

  • (Array)

    the current value of tags



18
19
20
# File 'lib/lastfm/track.rb', line 18

def tags
  @tags
end

#urlString

Returns the current value of url.

Returns:

  • (String)

    the current value of url



18
19
20
# File 'lib/lastfm/track.rb', line 18

def url
  @url
end

#wikiLastFM::Wii

Returns the current value of wiki.

Returns:

  • (LastFM::Wii)

    the current value of wiki



18
19
20
# File 'lib/lastfm/track.rb', line 18

def wiki
  @wiki
end

Instance Method Details

#update_from_node(node) ⇒ Object



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
53
54
# File 'lib/lastfm/track.rb', line 20

def update_from_node(node)
  case node.name.to_sym
    when :name
      self.name = node.content
    when :id
      self.id = node.content.to_i
    when :duration
      self.duration = node.content.to_i
    when :mbid
      self.mbid = node.content
    when :url
      self.url = 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')
      self.streamable_fulltrack = (node['fulltrack'] == '1')
    when :image
      self.images ||= {}
      self.images.merge!({node['size'].to_sym => node.content})
    when :artist
      self.artist = (node.find('*').count == 0) ? node.content : LastFM::Artist.from_xml(node)
    when :album
      self.position = node['position'].to_i
      self.album = LastFM::Album.from_xml(node)
    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