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 11 12 |
# File 'lib/lastfm/response.rb', line 8 def initialize(body) @xml = XmlSimple.xml_in(body, 'ForceArray' => ['image', 'tag', 'user', 'event', 'correction']) rescue REXML::ParseException @xml = XmlSimple.xml_in(body.encode(Encoding.find("ISO-8859-1"), :undef => :replace), '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
22 23 24 |
# File 'lib/lastfm/response.rb', line 22 def error @xml['error']['code'].to_i end |
#message ⇒ Object
18 19 20 |
# File 'lib/lastfm/response.rb', line 18 def @xml['error']['content'] end |
#success? ⇒ Boolean
14 15 16 |
# File 'lib/lastfm/response.rb', line 14 def success? @xml['status'] == 'ok' end |