Class: LightMeUp::SettingsUpdate
- Inherits:
-
Object
- Object
- LightMeUp::SettingsUpdate
- Defined in:
- lib/light_me_up/settings_update.rb
Defined Under Namespace
Classes: InvalidOptions, ToggleIncompatible
Instance Attribute Summary collapse
-
#api_client ⇒ Object
readonly
Returns the value of attribute api_client.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(api_client, options) ⇒ SettingsUpdate
constructor
A new instance of SettingsUpdate.
- #perform ⇒ Object
Constructor Details
#initialize(api_client, options) ⇒ SettingsUpdate
Returns a new instance of SettingsUpdate.
10 11 12 13 |
# File 'lib/light_me_up/settings_update.rb', line 10 def initialize(api_client, ) @api_client = api_client @options = end |
Instance Attribute Details
#api_client ⇒ Object (readonly)
Returns the value of attribute api_client.
5 6 7 |
# File 'lib/light_me_up/settings_update.rb', line 5 def api_client @api_client end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/light_me_up/settings_update.rb', line 5 def @options end |
Instance Method Details
#perform ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/light_me_up/settings_update.rb', line 15 def perform = .slice(:toggle, :on, :brightness, :temperature) if .delete(:toggle) raise ToggleIncompatible, "is not compatible with on or off" if .key?(:on) api_client.toggle(**) elsif .any? api_client.update(**) else raise InvalidOptions, "At least one option must be provided" end end |