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.



4192
4193
4194
4195
4196
4197
4198
4199
4200
# File 'lib/ruby-macrodroid.rb', line 4192

def initialize(h={})

  options = {
    enabled: true
  }

  super(options.merge h)

end

Instance Method Details

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

Returns:

  • (Boolean)


4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
# File 'lib/ruby-macrodroid.rb', line 4202

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



4225
4226
4227
4228
# File 'lib/ruby-macrodroid.rb', line 4225

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

#to_sObject



4230
4231
4232
4233
4234
4235
# File 'lib/ruby-macrodroid.rb', line 4230

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