Class: EchoNest::Response
- Inherits:
-
Object
- Object
- EchoNest::Response
- Defined in:
- lib/another_echonest_ruby_api/response.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
data attr is a Hashie::Mash you can use to get at json attributes returned ex: response.data.artist.name, response.data.artist.name etc.
-
#raw_json ⇒ Object
readonly
data attr is a Hashie::Mash you can use to get at json attributes returned ex: response.data.artist.name, response.data.artist.name etc.
-
#request ⇒ Object
readonly
data attr is a Hashie::Mash you can use to get at json attributes returned ex: response.data.artist.name, response.data.artist.name etc.
-
#status ⇒ Object
readonly
data attr is a Hashie::Mash you can use to get at json attributes returned ex: response.data.artist.name, response.data.artist.name etc.
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(opts = {}) ⇒ Response
constructor
A new instance of Response.
- #message ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Response
Returns a new instance of Response.
11 12 13 14 15 16 17 |
# File 'lib/another_echonest_ruby_api/response.rb', line 11 def initialize(opts={}) @request = opts[:request] @raw_json = opts[:raw_json] h = JSON.parse(@raw_json) @data = Hashie::Mash.new(h['response']) @status = data.status end |
Instance Attribute Details
#data ⇒ Object (readonly)
data attr is a Hashie::Mash you can use to get at json attributes returned ex: response.data.artist.name, response.data.artist.name etc
9 10 11 |
# File 'lib/another_echonest_ruby_api/response.rb', line 9 def data @data end |
#raw_json ⇒ Object (readonly)
data attr is a Hashie::Mash you can use to get at json attributes returned ex: response.data.artist.name, response.data.artist.name etc
9 10 11 |
# File 'lib/another_echonest_ruby_api/response.rb', line 9 def raw_json @raw_json end |
#request ⇒ Object (readonly)
data attr is a Hashie::Mash you can use to get at json attributes returned ex: response.data.artist.name, response.data.artist.name etc
9 10 11 |
# File 'lib/another_echonest_ruby_api/response.rb', line 9 def request @request end |
#status ⇒ Object (readonly)
data attr is a Hashie::Mash you can use to get at json attributes returned ex: response.data.artist.name, response.data.artist.name etc
9 10 11 |
# File 'lib/another_echonest_ruby_api/response.rb', line 9 def status @status end |
Instance Method Details
#error? ⇒ Boolean
19 20 21 |
# File 'lib/another_echonest_ruby_api/response.rb', line 19 def error? status.code != 0 end |
#message ⇒ Object
23 24 25 |
# File 'lib/another_echonest_ruby_api/response.rb', line 23 def status. end |
#version ⇒ Object
27 28 29 |
# File 'lib/another_echonest_ruby_api/response.rb', line 27 def version status.version end |