Class: ExternalPowerConstraint

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

Overview

Category: Battery/Power

Instance Attribute Summary

Attributes inherited from MacroObject

#options, #siguid, #type

Instance Method Summary collapse

Methods inherited from Constraint

#match?

Methods inherited from MacroObject

#to_h

Constructor Details

#initialize(h = {}) ⇒ ExternalPowerConstraint

Returns a new instance of ExternalPowerConstraint.



176
177
178
179
180
181
182
183
184
185
# File 'lib/ruby-macrodroid/constraints.rb', line 176

def initialize(h={})

  options = {
    external_power: true,
    power_connected_options: [false, true, false]
  }

  super(options.merge h)

end

Instance Method Details

#to_s(colour: false, indent: 0) ⇒ Object



187
188
189
190
# File 'lib/ruby-macrodroid/constraints.rb', line 187

def to_s(colour: false, indent: 0)
  connection = @h[:external_power] ? 'Connected' : 'Disconnected'
  'Power ' + connection
end