require 'rubygems' require 'json' class Lastfm class Response def initialize(body) # API returns XML response when no child node? if body == ' ' @parsed_body = {} else @parsed_body = JSON.parse(body) end end def [](key) @parsed_body[key] end def success? !self['error'] end def message self['message'] end def error self['error'] end end end