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.
5216 5217 5218 5219 5220 5221 5222 5223 5224 |
# File 'lib/ruby-macrodroid.rb', line 5216 def initialize(h={}) = { enabled: true } super(.merge h) end |
Instance Method Details
#match?(detail = {}, model = nil) ⇒ Boolean
5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 |
# File 'lib/ruby-macrodroid.rb', line 5226 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
5249 5250 5251 5252 |
# File 'lib/ruby-macrodroid.rb', line 5249 def to_pc() status = @h[:enabled] ? 'enabled?' : 'disabled?' 'airplane_mode.' + status end |
#to_s(colour: false) ⇒ Object Also known as: to_summary
5254 5255 5256 5257 5258 5259 |
# File 'lib/ruby-macrodroid.rb', line 5254 def to_s(colour: false) status = @h[:enabled] ? 'Enabled' : 'Disabled' 'Airplane Mode ' + status end |