Class: AirplaneModeConstraint
- Inherits:
-
Constraint
- Object
- MacroObject
- Constraint
- AirplaneModeConstraint
- Defined in:
- lib/ruby-macrodroid.rb
Overview
Category: Device State
Instance Attribute Summary
Attributes inherited from MacroObject
Instance Method Summary collapse
-
#initialize(h = {}) ⇒ AirplaneModeConstraint
constructor
A new instance of AirplaneModeConstraint.
- #match?(detail = {}, model = nil) ⇒ Boolean
- #to_pc ⇒ Object
- #to_s(colour: false) ⇒ Object (also: #to_summary)
Methods inherited from MacroObject
Constructor Details
#initialize(h = {}) ⇒ AirplaneModeConstraint
Returns a new instance of AirplaneModeConstraint.
5230 5231 5232 5233 5234 5235 5236 5237 5238 |
# File 'lib/ruby-macrodroid.rb', line 5230 def initialize(h={}) = { enabled: true } super(.merge h) end |
Instance Method Details
#match?(detail = {}, model = nil) ⇒ Boolean
5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 |
# File 'lib/ruby-macrodroid.rb', line 5240 def match?(detail={}, model=nil) puts 'inside airplaneModeConstraint#match?' if $debug if detail.has_key? :enabled then puts 'detail has the key' if $debug super(detail) elsif model if $debug then puts 'checking the model' switch = model.connectivity.airplane_mode.switch puts 'switch: ' + switch.inspect end toggle_match?(:enabled, switch) end end |
#to_pc ⇒ Object
5263 5264 5265 5266 |
# File 'lib/ruby-macrodroid.rb', line 5263 def to_pc() status = @h[:enabled] ? 'enabled?' : 'disabled?' 'airplane_mode.' + status end |
#to_s(colour: false) ⇒ Object Also known as: to_summary
5268 5269 5270 5271 5272 5273 |
# File 'lib/ruby-macrodroid.rb', line 5268 def to_s(colour: false) status = @h[:enabled] ? 'Enabled' : 'Disabled' 'Airplane Mode ' + status end |