Class: Wizrb::Shared::State
- Inherits:
-
Object
- Object
- Wizrb::Shared::State
- Defined in:
- lib/wizrb/shared/state.rb
Direct Known Subclasses
Constant Summary collapse
- STATE_KEYS =
%i[state].freeze
Instance Method Summary collapse
-
#initialize ⇒ State
constructor
A new instance of State.
- #parse!(response) ⇒ Object
- #power ⇒ Object
- #to_json(*_args) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ State
Returns a new instance of State.
8 9 10 |
# File 'lib/wizrb/shared/state.rb', line 8 def initialize @state = {state: false} end |
Instance Method Details
#parse!(response) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/wizrb/shared/state.rb', line 12 def parse!(response) result = response&.dig("result") return unless result @state = result.transform_keys(&:to_sym).slice(*STATE_KEYS) end |
#power ⇒ Object
19 20 21 |
# File 'lib/wizrb/shared/state.rb', line 19 def power @state[:state] end |
#to_json(*_args) ⇒ Object
27 28 29 |
# File 'lib/wizrb/shared/state.rb', line 27 def to_json(*_args) @state.to_json end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/wizrb/shared/state.rb', line 23 def to_s @state.to_s end |