Class: NRB::HTTPService::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/drink-socially/http_service/response.rb

Direct Known Subclasses

Untappd::API::Object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Response

Returns a new instance of Response.



14
15
16
17
18
# File 'lib/drink-socially/http_service/response.rb', line 14

def initialize(args)
  @status = args[:status]
  @body = Hashie::Mash.new args[:body]
  @headers = Hashie::Mash.new args[:headers]
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



7
8
9
# File 'lib/drink-socially/http_service/response.rb', line 7

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



7
8
9
# File 'lib/drink-socially/http_service/response.rb', line 7

def headers
  @headers
end

#statusObject (readonly)

Returns the value of attribute status.



7
8
9
# File 'lib/drink-socially/http_service/response.rb', line 7

def status
  @status
end

Instance Method Details

#errored?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/drink-socially/http_service/response.rb', line 9

def errored?
  ! success?
end

#success?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/drink-socially/http_service/response.rb', line 21

def success?
  @status >= 200 && @status < 300
end