class ProximityTrigger

Category: Sensors

Public Class Methods

new(obj=nil) click to toggle source
Calls superclass method SensorsTrigger::new
# File lib/ruby-macrodroid/triggers.rb, line 1456
def initialize(obj=nil)

  h = if obj.is_a? Hash then
    obj
  elsif obj.is_a? Array
    e, macro = obj
    txt = e.text('item/description')
    {option: (txt || e.text), macro: macro}
  end 
  
  options = {
    near: true,
    selected_option: 0
  }
  
  if h[:distance] then
    
    case h[:distance].to_sym
    when :near
      options[:near] = true
    end
  end
  
  super(options.merge h)

end

Public Instance Methods

match?(detail={}, model=nil) click to toggle source
# File lib/ruby-macrodroid/triggers.rb, line 1483
def match?(detail={}, model=nil)
  @h[:selected_option] == detail[:option].to_i
end
to_s(colour: false) click to toggle source
Calls superclass method Trigger#to_s
# File lib/ruby-macrodroid/triggers.rb, line 1487
def to_s(colour: false)
  
  distance = if @h[:near] then
    'Near'
  else
    'Far'
  end
  
  @s = "Proximity Sensor (%s)" % distance
  super()
end
Also aliased as: to_summary
to_summary(colour: false)
Alias for: to_s