Class: ExternalPowerTrigger

Inherits:
Trigger show all
Defined in:
lib/ruby-macrodroid.rb

Overview

Category: Battery/Power

Instance Attribute Summary

Attributes inherited from Trigger

#constraints

Attributes inherited from MacroObject

#options, #siguid, #type

Instance Method Summary collapse

Methods inherited from Trigger

#match?

Methods inherited from MacroObject

#to_h

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={})

  options = {
    power_connected_options: [true, true, true],
    has_set_usb_option: true,
    power_connected: true,
    has_set_new_power_connected_options: true
  }

  super(options.merge h)

end

Instance Method Details

#to_sObject



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'
  options = 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, options]
end