Class: AirplaneModeConstraint

Inherits:
Constraint show all
Defined in:
lib/ruby-macrodroid.rb

Overview

Category: Device State

Instance Attribute Summary

Attributes inherited from MacroObject

#options, #siguid, #type

Instance Method Summary collapse

Methods inherited from MacroObject

#to_h

Constructor Details

#initialize(h = {}) ⇒ AirplaneModeConstraint

Returns a new instance of AirplaneModeConstraint.



4505
4506
4507
4508
4509
4510
4511
4512
4513
# File 'lib/ruby-macrodroid.rb', line 4505

def initialize(h={})

  options = {
    enabled: true
  }

  super(options.merge h)

end

Instance Method Details

#match?(detail = {}, model = nil) ⇒ Boolean

Returns:

  • (Boolean)


4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
# File 'lib/ruby-macrodroid.rb', line 4515

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_pcObject



4538
4539
4540
4541
# File 'lib/ruby-macrodroid.rb', line 4538

def to_pc()
  status = @h[:enabled] ? 'enabled?' : 'disabled?'
  'airplane_mode.' + status
end

#to_sObject



4543
4544
4545
4546
4547
4548
# File 'lib/ruby-macrodroid.rb', line 4543

def to_s()
  
  status = @h[:enabled] ? 'Enabled' : 'Disabled'
  'Airplane Mode ' + status
  
end