Class: ProximityTrigger

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

Overview

Category: Sensors

Instance Attribute Summary

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.



2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
# File 'lib/ruby-macrodroid.rb', line 2116

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



2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
# File 'lib/ruby-macrodroid.rb', line 2135

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