Class: ProximityTrigger

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

Overview

Category: Sensors

Instance Attribute Summary

Attributes inherited from Trigger

#constraints

Attributes inherited from MacroObject

#options, #siguid, #type

Instance Method Summary collapse

Methods inherited from Trigger

#match?

Methods inherited from MacroObject

#to_h

Constructor Details

#initialize(h = {}) ⇒ ProximityTrigger

Returns a new instance of ProximityTrigger.



2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
# File 'lib/ruby-macrodroid.rb', line 2270

def initialize(h={})

  if h[:distance] then
    
    case h[:distance].to_sym
    when :near
      options[:near] = true
    end
  end
  
  options = {
    near: true,
    selected_option: 0
  }

  super(options.merge filter(options,h))

end

Instance Method Details

#to_sObject



2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
# File 'lib/ruby-macrodroid.rb', line 2289

def to_s()
  
  distance = if @h[:near] then
    'Near'
  else
    'Far'
  end
  
  "Proximity Sensor (%s)" % distance
end