Class: ProximityTrigger

Inherits:
SensorsTrigger show all
Defined in:
lib/ruby-macrodroid/triggers.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.



1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
# File 'lib/ruby-macrodroid/triggers.rb', line 1307

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 h)

end

Instance Method Details

#to_s(colour: false) ⇒ Object Also known as: to_summary



1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
# File 'lib/ruby-macrodroid/triggers.rb', line 1326

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