Class: HyperionResult
- Inherits:
-
Object
- Object
- HyperionResult
- Defined in:
- lib/hyperion/types/hyperion_result.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#route ⇒ Object
readonly
Returns the value of attribute route.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #as_json(*_args) ⇒ Object
-
#initialize(route, status, code = nil, body = nil) ⇒ HyperionResult
constructor
A new instance of HyperionResult.
- #to_s ⇒ Object
Constructor Details
#initialize(route, status, code = nil, body = nil) ⇒ HyperionResult
Returns a new instance of HyperionResult.
12 13 14 |
# File 'lib/hyperion/types/hyperion_result.rb', line 12 def initialize(route, status, code=nil, body=nil) @route, @status, @code, @body = route, status, code, body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
4 5 6 |
# File 'lib/hyperion/types/hyperion_result.rb', line 4 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
4 5 6 |
# File 'lib/hyperion/types/hyperion_result.rb', line 4 def code @code end |
#route ⇒ Object (readonly)
Returns the value of attribute route.
4 5 6 |
# File 'lib/hyperion/types/hyperion_result.rb', line 4 def route @route end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/hyperion/types/hyperion_result.rb', line 4 def status @status end |
Instance Method Details
#as_json(*_args) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/hyperion/types/hyperion_result.rb', line 16 def as_json(*_args) { 'route' => route.as_json(*_args), 'status' => status.value, 'code' => code, 'body' => body.as_json(*_args), } end |
#to_s ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/hyperion/types/hyperion_result.rb', line 25 def to_s if status == HyperionStatus::CHECK_CODE "HTTP #{code}: #{route.to_s}" elsif status == HyperionStatus::BAD_ROUTE "#{status.value.to_s.humanize} (#{code}): #{route.to_s}" else "#{status.value.to_s.humanize}: #{route.to_s}" end end |