Sha256: f5783f28c0ad702ccb01bbd484ddd45729bede62cc46d4fdec3e815ac12af813

Contents?: true

Size: 512 Bytes

Versions: 2

Compression:

Stored size: 512 Bytes

Contents

module Mopidy
  class Response
    def initialize(response)
      @response = response
    end

    def status
      @response.code
    end

    def body
      has_error?(@response) ? parse_error(@response) : parse_response(@response)
    end

    private

    def has_error?(response)
      response.parsed_response['result'].nil?
    end

    def parse_response(response)
      response.parsed_response['result']
    end

    def parse_error(response)
      response.parsed_response['error']
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
ruby-mopidy-0.2.1 lib/mopidy/response.rb
mopidy-0.2.0 lib/mopidy/response.rb