Class: LastFM::Album

Inherits:
Result show all
Defined in:
lib/last_fm/album.rb

Instance Attribute Summary collapse

Attributes inherited from Result

#id, #image, #images, #name, #url

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Album

Returns a new instance of Album.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/last_fm/album.rb', line 5

def initialize(attributes)
  super(attributes)

  @mbid = attributes['mbid'] if attributes['mbid']
  @artist = attributes['artist'] if attributes['artist']


  if attributes['releasedate'] and attributes['releasedate'].gsub(/\s+/, '').length > 0
    @released = Date.parse(attributes['releasedate'])
  end

  @tracks = []
  if attributes['tracks'] and attributes['tracks']['track']
    attributes['tracks']['track'].each do |track|
      @tracks << Track.new(track['name'], track['duration'], track['mbid'], track['url'])
    end
  end
end

Instance Attribute Details

#artistObject (readonly)

Returns the value of attribute artist.



3
4
5
# File 'lib/last_fm/album.rb', line 3

def artist
  @artist
end

#mbidObject (readonly)

Returns the value of attribute mbid.



3
4
5
# File 'lib/last_fm/album.rb', line 3

def mbid
  @mbid
end

#releasedObject (readonly)

Returns the value of attribute released.



3
4
5
# File 'lib/last_fm/album.rb', line 3

def released
  @released
end

#tracksObject (readonly)

Returns the value of attribute tracks.



3
4
5
# File 'lib/last_fm/album.rb', line 3

def tracks
  @tracks
end

Class Method Details

.get_info(artist, album) ⇒ Object



29
30
31
# File 'lib/last_fm/album.rb', line 29

def get_info(artist, album)
  Query.get_info({ method: 'album.getInfo', artist: artist, album: album })
end

.search(album) ⇒ Object



25
26
27
# File 'lib/last_fm/album.rb', line 25

def search(album)
  Query.search({ method: 'album.search', album: album })
end