Class: LastFM::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/last_fm/result.rb

Direct Known Subclasses

Album, Artist

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Result

Returns a new instance of Result.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/last_fm/result.rb', line 5

def initialize(attributes)
  @id = attributes['id']
  @url = attributes['url']
  @name = attributes['name']

  @images = {}
  attributes['image'].each do |image|
    @images[image['size'].to_sym] = image['#text']
  end
  @image = @images[:large]
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#imageObject (readonly)

Returns the value of attribute image.



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

def image
  @image
end

#imagesObject (readonly)

Returns the value of attribute images.



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

def images
  @images
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#urlObject (readonly)

Returns the value of attribute url.



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

def url
  @url
end