Class: AirplaneModeConstraint

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

Overview

Category: Device State

Instance Attribute Summary

Attributes inherited from MacroObject

#options, #type

Instance Method Summary collapse

Methods inherited from MacroObject

#to_h

Constructor Details

#initialize(h = {}) ⇒ AirplaneModeConstraint

Returns a new instance of AirplaneModeConstraint.



3460
3461
3462
3463
3464
3465
3466
3467
3468
# File 'lib/ruby-macrodroid.rb', line 3460

def initialize(h={})

  options = {
    enabled: true
  }

  super(options.merge h)

end

Instance Method Details

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

Returns:

  • (Boolean)


3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
# File 'lib/ruby-macrodroid.rb', line 3470

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