Class: CoachClient::Response

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

Overview

A response from RESTful request to the CyberCoach service.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(header, body, code) ⇒ CoachClient::Response

Creates a new response.



16
17
18
19
20
# File 'lib/coach_client/response.rb', line 16

def initialize(header, body, code)
  @header = header
  @body = body
  @code = code
end

Instance Attribute Details

#codeInteger (readonly)



5
6
7
# File 'lib/coach_client/response.rb', line 5

def code
  @code
end

#headerString (readonly)



8
9
10
# File 'lib/coach_client/response.rb', line 8

def header
  @header
end

Instance Method Details

#to_hHash

Returns the body as Ruby Hash.



25
26
27
# File 'lib/coach_client/response.rb', line 25

def to_h
  JSON.parse(@body, symbolize_names: true)
end

#to_sString

Returns the body as String.



32
33
34
# File 'lib/coach_client/response.rb', line 32

def to_s
  @body.to_s
end