Class: ExternalPowerTrigger
- Inherits:
-
Trigger
- Object
- MacroObject
- Trigger
- ExternalPowerTrigger
- Defined in:
- lib/ruby-macrodroid.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 ⇒ Object
Methods inherited from Trigger
Methods inherited from MacroObject
Constructor Details
#initialize(h = {}) ⇒ ExternalPowerTrigger
Returns a new instance of ExternalPowerTrigger.
1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 |
# File 'lib/ruby-macrodroid.rb', line 1357 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 ⇒ Object
1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 |
# File 'lib/ruby-macrodroid.rb', line 1370 def to_s() 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 |