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, #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.



2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
# File 'lib/ruby-macrodroid.rb', line 2186

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



2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
# File 'lib/ruby-macrodroid.rb', line 2205

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