Class: Yelp4r::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



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

def initialize(response)
  @body = rash_response(response)
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



4
5
6
# File 'lib/yelp4r/response.rb', line 4

def body
  @body
end

Instance Method Details

#dataObject



22
23
24
25
26
27
28
# File 'lib/yelp4r/response.rb', line 22

def data
  if !@body.businesses.blank?
    @body.businesses
  elsif !@body.neighborhoods.blank?
    @body.neighborhoods
  end
end

#error_messageObject



18
19
20
# File 'lib/yelp4r/response.rb', line 18

def error_message
  @body.message.text unless success?
end

#response_codeObject



10
11
12
# File 'lib/yelp4r/response.rb', line 10

def response_code
  @body.message.code
end

#success?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/yelp4r/response.rb', line 14

def success?
  response_code == 0
end