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.



4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
# File 'lib/ruby-macrodroid.rb', line 4778

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



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

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