Class: Echonest::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/echonest/response.rb

Defined Under Namespace

Classes: Status

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body) ⇒ Response

Returns a new instance of Response.



8
9
10
# File 'lib/echonest/response.rb', line 8

def initialize(body)
  @json = Hashie::Mash.new(JSON.parse(body))
end

Instance Attribute Details

#jsonObject (readonly)

Returns the value of attribute json.



6
7
8
# File 'lib/echonest/response.rb', line 6

def json
  @json
end

Instance Method Details

#bodyObject



20
21
22
# File 'lib/echonest/response.rb', line 20

def body
  json.response
end

#statusObject



12
13
14
# File 'lib/echonest/response.rb', line 12

def status
  @status ||= Status.new(body)
end

#success?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/echonest/response.rb', line 16

def success?
  status.code == Status::SUCCESS
end