Class: MyTado::Response::AbstractResponse
- Inherits:
-
Object
- Object
- MyTado::Response::AbstractResponse
- Defined in:
- lib/my_tado/response/abstract_response.rb
Overview
Make response a bit easier to deal with in Ruby, largely by converting datetimes to Ruby DateTime objects
Instance Attribute Summary collapse
-
#raw_response ⇒ Object
readonly
Returns the value of attribute raw_response.
Instance Method Summary collapse
-
#initialize(raw_response) ⇒ AbstractResponse
constructor
A new instance of AbstractResponse.
- #method_missing(method_name, *args, &block) ⇒ Object
- #ok? ⇒ Boolean
- #parse ⇒ Object
- #respond_to_missing?(method_name, *_args) ⇒ Boolean
Constructor Details
#initialize(raw_response) ⇒ AbstractResponse
Returns a new instance of AbstractResponse.
12 13 14 15 |
# File 'lib/my_tado/response/abstract_response.rb', line 12 def initialize(raw_response) @raw_response = raw_response parse end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/my_tado/response/abstract_response.rb', line 25 def method_missing(method_name, *args, &block) if @parsed_response.respond_to?(method_name) @parsed_response.public_send(method_name, *args, &block) else super end end |
Instance Attribute Details
#raw_response ⇒ Object (readonly)
Returns the value of attribute raw_response.
10 11 12 |
# File 'lib/my_tado/response/abstract_response.rb', line 10 def raw_response @raw_response end |
Instance Method Details
#ok? ⇒ Boolean
17 18 19 |
# File 'lib/my_tado/response/abstract_response.rb', line 17 def ok? raw_response.ok? end |
#parse ⇒ Object
21 22 23 |
# File 'lib/my_tado/response/abstract_response.rb', line 21 def parse @parsed_response = recursive_parse(raw_response.parsed_response) end |
#respond_to_missing?(method_name, *_args) ⇒ Boolean
33 34 35 |
# File 'lib/my_tado/response/abstract_response.rb', line 33 def respond_to_missing?(method_name, *_args) @parsed_response.respond_to?(method_name) end |