Class: ExternalPowerTrigger
- Inherits:
-
Trigger
- Object
- MacroObject
- Trigger
- ExternalPowerTrigger
- Defined in:
- lib/ruby-macrodroid/triggers.rb
Overview
Category: Battery/Power
Instance Attribute Summary
Attributes inherited from Trigger
Attributes inherited from MacroObject
Instance Method Summary collapse
-
#initialize(h = {}) ⇒ ExternalPowerTrigger
constructor
A new instance of ExternalPowerTrigger.
- #to_s(colour: false) ⇒ Object (also: #to_summary)
Methods inherited from Trigger
Methods inherited from MacroObject
Constructor Details
#initialize(h = {}) ⇒ ExternalPowerTrigger
Returns a new instance of ExternalPowerTrigger.
230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/ruby-macrodroid/triggers.rb', line 230 def initialize(h={}) = { power_connected_options: [true, true, true], has_set_usb_option: true, power_connected: true, has_set_new_power_connected_options: true } super(.merge h) end |
Instance Method Details
#to_s(colour: false) ⇒ Object Also known as: to_summary
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/ruby-macrodroid/triggers.rb', line 243 def to_s(colour: false) return 'Power Disconnected' unless @h[:power_connected] status = 'Power Connectd' = if @h[:power_connected_options].all? then 'Any' else a = ['Wired (Fast Charge)', 'Wireless', 'Wired (Slow Charge)'] @h[:power_connected_options].map.with_index {|x,i| x ? i : nil}\ .compact.map {|i| a[i] }.join(' + ') end "%s: %s" % [status, ] end |