class GeofenceTrigger

Category: Location

Public Class Methods

new( h={}, geofences: {}) click to toggle source
Calls superclass method Trigger::new
# File lib/ruby-macrodroid/triggers.rb, line 1294
def initialize( h={}, geofences: {})

  if h[:name] then
    puts ('geofences2: ' + geofences.inspect) if $debug
    found = geofences.find {|x| x.name.downcase == h[:name].downcase}
    h[:geofence_id] = found.id if found
    
  end
  
  options = {
    update_rate_text: '5 Minutes',
    geofence_id: '',
    geofence_update_rate_minutes: 5,
    trigger_from_unknown: false,
    enter_area: true
  }

  super(options.merge filter(options, h))
  @geofences = geofences

end

Public Instance Methods

to_s(colour: false) click to toggle source
# File lib/ruby-macrodroid/triggers.rb, line 1316
def to_s(colour: false)
  
  if $debug then
    puts ' @geofences: ' + @geofences.inspect
    puts '@h: ' + @h.inspect
    puts '@h[:geofence_id]: ' + @h[:geofence_id].inspect
  end
  
  direction = @h[:enter_area] ? 'Entry' : 'Exit'
  
  found = @geofences.find {|x| x.id == @h[:geofence_id]}
  puts 'found: ' + found.inspect    if @debug 
  label = found ? found.name : 'error: name not found'

  "Geofence %s (%s)" % [direction, label]
  
end