class BatteryLevelConstraint

Category: Battery/Power

Public Class Methods

new(h={}) click to toggle source
Calls superclass method Constraint::new
# File lib/ruby-macrodroid/constraints.rb, line 97
def initialize(h={})

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

  super(options.merge h)

end

Public Instance Methods

to_s(colour: false, indent: 0) click to toggle source
# File lib/ruby-macrodroid/constraints.rb, line 109
def to_s(colour: false, indent: 0)
  
  operator = if @h[:greater_than] then
    '>'
  elsif @h[:equals]
    '='
  else
    '<'
  end
  
  level = @h[:battery_level]
  
  "Battery %s %s%%" % [operator, level]
end
Also aliased as: to_summary
to_summary(colour: false, indent: 0)
Alias for: to_s