Class: Lastfm::Response
- Inherits:
-
Object
- Object
- Lastfm::Response
- Defined in:
- lib/lastfm/response.rb
Instance Attribute Summary collapse
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Instance Method Summary collapse
- #error ⇒ Object
-
#initialize(body) ⇒ Response
constructor
A new instance of Response.
- #message ⇒ Object
- #success? ⇒ Boolean
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
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
6 7 8 |
# File 'lib/lastfm/response.rb', line 6 def xml @xml end |
Instance Method Details
#error ⇒ Object
20 21 22 |
# File 'lib/lastfm/response.rb', line 20 def error @xml['error']['code'].to_i end |
#message ⇒ Object
16 17 18 |
# File 'lib/lastfm/response.rb', line 16 def @xml['error']['content'] end |
#success? ⇒ Boolean
12 13 14 |
# File 'lib/lastfm/response.rb', line 12 def success? @xml['status'] == 'ok' end |