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(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.
1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 |
# File 'lib/ruby-macrodroid.rb', line 1436 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
1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 |
# File 'lib/ruby-macrodroid.rb', line 1449 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 |