Class: BatteryLevelTrigger

Inherits:
Trigger show all
Defined in:
lib/ruby-macrodroid/triggers.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 = {}) ⇒ BatteryLevelTrigger

Returns a new instance of BatteryLevelTrigger.



149
150
151
152
153
154
155
156
157
158
159
# File 'lib/ruby-macrodroid/triggers.rb', line 149

def initialize(h={})

  options = {
    battery_level: 50,
    decreases_to: true,
    option: 0
  }

  super(options.merge h)

end

Instance Method Details

#to_s(colour: false) ⇒ Object



161
162
163
164
# File 'lib/ruby-macrodroid/triggers.rb', line 161

def to_s(colour: false)
  operator = @h[:decreases_to] ? '<=' : '>='    
  "Battery %s %s%%" % [operator, @h[:battery_level]]
end