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.



4365
4366
4367
4368
4369
4370
4371
4372
4373
# File 'lib/ruby-macrodroid.rb', line 4365

def initialize(h={})

  options = {
    enabled: true
  }

  super(options.merge h)

end

Instance Method Details

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

Returns:

  • (Boolean)


4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
# File 'lib/ruby-macrodroid.rb', line 4375

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



4398
4399
4400
4401
# File 'lib/ruby-macrodroid.rb', line 4398

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

#to_sObject



4403
4404
4405
4406
4407
4408
# File 'lib/ruby-macrodroid.rb', line 4403

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