Class: BatteryLevelConstraint
- Inherits:
-
Constraint
- Object
- MacroObject
- Constraint
- BatteryLevelConstraint
- Defined in:
- lib/ruby-macrodroid/constraints.rb
Overview
Category: Battery/Power
Instance Attribute Summary
Attributes inherited from MacroObject
Instance Method Summary collapse
-
#initialize(h = {}) ⇒ BatteryLevelConstraint
constructor
A new instance of BatteryLevelConstraint.
- #to_s(colour: false, indent: 0) ⇒ Object (also: #to_summary)
Methods inherited from Constraint
Methods inherited from MacroObject
Constructor Details
#initialize(h = {}) ⇒ BatteryLevelConstraint
Returns a new instance of BatteryLevelConstraint.
97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/ruby-macrodroid/constraints.rb', line 97 def initialize(h={}) = { battery_level: 23, equals: false, greater_than: false } super(.merge h) end |
Instance Method Details
#to_s(colour: false, indent: 0) ⇒ Object Also known as: to_summary
109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# 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 |