Class: BatteryLevelTrigger

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, #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.



1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
# File 'lib/ruby-macrodroid.rb', line 1251

def initialize(h={})

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

  super(options.merge h)

end

Instance Method Details

#to_sObject



1263
1264
1265
1266
# File 'lib/ruby-macrodroid.rb', line 1263

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