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.



2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
# File 'lib/ruby-macrodroid.rb', line 2518

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_s(colour: false) ⇒ Object



2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
# File 'lib/ruby-macrodroid.rb', line 2537

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