Class: Fitting::Records::Spherical::Response
- Inherits:
-
Object
- Object
- Fitting::Records::Spherical::Response
- Defined in:
- lib/fitting/records/spherical/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(status:, body:) ⇒ Response
constructor
A new instance of Response.
- #to_hash ⇒ Object
- #to_json(*_args) ⇒ Object
Constructor Details
#initialize(status:, body:) ⇒ Response
Returns a new instance of Response.
9 10 11 12 |
# File 'lib/fitting/records/spherical/response.rb', line 9 def initialize(status:, body:) @status = status @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
7 8 9 |
# File 'lib/fitting/records/spherical/response.rb', line 7 def body @body end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
7 8 9 |
# File 'lib/fitting/records/spherical/response.rb', line 7 def status @status end |
Class Method Details
.load(hash) ⇒ Object
31 32 33 |
# File 'lib/fitting/records/spherical/response.rb', line 31 def load(hash) new(status: hash['status'], body: hash['body']) end |
Instance Method Details
#to_hash ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fitting/records/spherical/response.rb', line 14 def to_hash { status: status, body: JSON.parse(body) } rescue JSON::ParserError { status: status, body: {} } end |
#to_json(*_args) ⇒ Object
26 27 28 |
# File 'lib/fitting/records/spherical/response.rb', line 26 def to_json(*_args) JSON.dump(to_hash) end |