Class: BatteryLevelConstraint

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

Returns a new instance of BatteryLevelConstraint.



4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
# File 'lib/ruby-macrodroid.rb', line 4151

def initialize(h={})

  options = {
    battery_level: 23,
    equals: false,
    greater_than: false
  }

  super(options.merge h)

end

Instance Method Details

#to_sObject



4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
# File 'lib/ruby-macrodroid.rb', line 4163

def to_s()
  
  operator = if @h[:greater_than] then
    '>'
  elsif @h[:equals]
    '='
  else
    '<'
  end
  
  level = @h[:battery_level]
  
  "Battery %s %s%%" % [operator, level]
end