Class: CoachClient::Response
- Inherits:
-
Object
- Object
- CoachClient::Response
- Defined in:
- lib/coach_client/response.rb
Overview
A response from RESTful request to the CyberCoach service.
Instance Attribute Summary collapse
-
#code ⇒ Integer
readonly
The HTTP code.
-
#header ⇒ String
readonly
The HTTP headers.
Instance Method Summary collapse
-
#initialize(header, body, code) ⇒ CoachClient::Response
constructor
Creates a new response.
-
#to_h ⇒ Hash
Returns the body as Ruby Hash.
-
#to_s ⇒ String
Returns the body as String.
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
#code ⇒ Integer (readonly)
Returns the HTTP code.
5 6 7 |
# File 'lib/coach_client/response.rb', line 5 def code @code end |
#header ⇒ String (readonly)
Returns the HTTP headers.
8 9 10 |
# File 'lib/coach_client/response.rb', line 8 def header @header end |
Instance Method Details
#to_h ⇒ Hash
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_s ⇒ String
Returns the body as String.
32 33 34 |
# File 'lib/coach_client/response.rb', line 32 def to_s @body.to_s end |