Class: Tolq::Api::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/tolq-api/response.rb

Overview

Wraps the responses of the Tolq Api

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status:, body:) ⇒ Response

Returns a new instance of Response.

Raises:

  • (ArgumentError)


7
8
9
10
11
12
# File 'lib/tolq-api/response.rb', line 7

def initialize(status:, body:)
  raise ArgumentError.new('Expected body to be a string') unless !body || body.is_a?(String)

  @status = status.to_i
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



5
6
7
# File 'lib/tolq-api/response.rb', line 5

def body
  @body
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/tolq-api/response.rb', line 5

def status
  @status
end

Instance Method Details

#==(other) ⇒ Object



14
15
16
# File 'lib/tolq-api/response.rb', line 14

def ==(other)
  self.status == other.status && self.body == other.body
end