Class: MachineGun::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/machine-gun/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Response

Returns a new instance of Response.



8
9
10
11
12
13
14
15
# File 'lib/machine-gun/response.rb', line 8

def initialize(id)
  response = Commands.response(id)

  @id = id
  @status_code = response["status_code"]
  @headers = response["headers"]
  @payload = response["payload"]
end

Instance Attribute Details

#headersObject

Returns the value of attribute headers.



5
6
7
# File 'lib/machine-gun/response.rb', line 5

def headers
  @headers
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/machine-gun/response.rb', line 3

def id
  @id
end

#payloadObject

Returns the value of attribute payload.



6
7
8
# File 'lib/machine-gun/response.rb', line 6

def payload
  @payload
end

#status_codeObject

Returns the value of attribute status_code.



4
5
6
# File 'lib/machine-gun/response.rb', line 4

def status_code
  @status_code
end

Instance Method Details

#payload_as_jsonObject



17
18
19
# File 'lib/machine-gun/response.rb', line 17

def payload_as_json
  JSON.load(@payload)
end