Class: AirplaneModeConstraint
- Inherits:
-
Constraint
- Object
- MacroObject
- Constraint
- AirplaneModeConstraint
- Defined in:
- lib/ruby-macrodroid/constraints.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, indent: 0) ⇒ Object (also: #to_summary)
Methods inherited from MacroObject
Constructor Details
#initialize(h = {}) ⇒ AirplaneModeConstraint
Returns a new instance of AirplaneModeConstraint.
571 572 573 574 575 576 577 578 579 |
# File 'lib/ruby-macrodroid/constraints.rb', line 571 def initialize(h={}) = { enabled: true } super(.merge h) end |
Instance Method Details
#match?(detail = {}, model = nil) ⇒ Boolean
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 |
# File 'lib/ruby-macrodroid/constraints.rb', line 581 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
604 605 606 607 |
# File 'lib/ruby-macrodroid/constraints.rb', line 604 def to_pc() status = @h[:enabled] ? 'enabled?' : 'disabled?' 'airplane_mode.' + status end |
#to_s(colour: false, indent: 0) ⇒ Object Also known as: to_summary
609 610 611 612 613 614 |
# File 'lib/ruby-macrodroid/constraints.rb', line 609 def to_s(colour: false, indent: 0) status = @h[:enabled] ? 'Enabled' : 'Disabled' 'Airplane Mode ' + status end |