Class: Llmclt::Response::Base
- Inherits:
-
Object
- Object
- Llmclt::Response::Base
- Defined in:
- lib/llmclt/response/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#response_orig ⇒ Object
readonly
Returns the value of attribute response_orig.
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(response) ⇒ Base
constructor
A new instance of Base.
- #status ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ Base
Returns a new instance of Base.
8 9 10 11 12 13 |
# File 'lib/llmclt/response/base.rb', line 8 def initialize(response) @response_orig = response @response = JSON.parse(response.body) if response.body rescue JSON::ParserError @response = nil end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/llmclt/response/base.rb', line 6 def response @response end |
#response_orig ⇒ Object (readonly)
Returns the value of attribute response_orig.
6 7 8 |
# File 'lib/llmclt/response/base.rb', line 6 def response_orig @response_orig end |
Instance Method Details
#error? ⇒ Boolean
23 24 25 |
# File 'lib/llmclt/response/base.rb', line 23 def error? status.between?(400, 599) end |
#status ⇒ Object
15 16 17 |
# File 'lib/llmclt/response/base.rb', line 15 def status response_orig.code.to_i end |
#success? ⇒ Boolean
19 20 21 |
# File 'lib/llmclt/response/base.rb', line 19 def success? status == 200 end |