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.



4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
# File 'lib/ruby-macrodroid.rb', line 4792

def initialize(h={})

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

  super(options.merge h)

end

Instance Method Details

#to_s(colour: false) ⇒ Object Also known as: to_summary



4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
# File 'lib/ruby-macrodroid.rb', line 4804

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