Class: Lastfm::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body) ⇒ Response

Returns a new instance of Response.



8
9
10
# File 'lib/lastfm/response.rb', line 8

def initialize(body)
  @xml = XmlSimple.xml_in(body, 'ForceArray' => ['image', 'tag', 'user', 'event', 'correction'])
end

Instance Attribute Details

#xmlObject (readonly)

Returns the value of attribute xml.



6
7
8
# File 'lib/lastfm/response.rb', line 6

def xml
  @xml
end

Instance Method Details

#errorObject



20
21
22
# File 'lib/lastfm/response.rb', line 20

def error
  @xml['error']['code'].to_i
end

#messageObject



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

def message
  @xml['error']['content']
end

#success?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/lastfm/response.rb', line 12

def success?
  @xml['status'] == 'ok'
end