Sha256: ffe3089c17033906ece6a3916c43cfe0583bc09b8232874d38ddfa52b9697900

Contents?: true

Size: 593 Bytes

Versions: 18

Compression:

Stored size: 593 Bytes

Contents

require 'rubygems'
require 'xmlsimple'

class Lastfm
  class Response
    attr_reader :xml

    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

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

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

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

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
lastfm-1.27.0 lib/lastfm/response.rb
lastfm-1.26.0 lib/lastfm/response.rb
lastfm-1.25.0 lib/lastfm/response.rb
lastfm-1.24.0 lib/lastfm/response.rb
lastfm-1.23.0 lib/lastfm/response.rb
lastfm-1.22.0 lib/lastfm/response.rb
lastfm-1.21.0 lib/lastfm/response.rb
lastfm-1.20.1 lib/lastfm/response.rb
lastfm-1.19.1 lib/lastfm/response.rb
lastfm-1.19.0 lib/lastfm/response.rb
lastfm-1.18.0 lib/lastfm/response.rb
lastfm-1.17.0 lib/lastfm/response.rb
lastfm-1.16.0 lib/lastfm/response.rb
lastfm-1.15.1 lib/lastfm/response.rb
lastfm-1.15.0 lib/lastfm/response.rb
lastfm-1.14.1 lib/lastfm/response.rb
lastfm-1.14.0 lib/lastfm/response.rb
lastfm-1.13.1 lib/lastfm/response.rb