Class: GeofenceTrigger

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

Overview

Category: Location

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 = {}, geofences: {}) ⇒ GeofenceTrigger

Returns a new instance of GeofenceTrigger.



2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
# File 'lib/ruby-macrodroid.rb', line 2006

def initialize( h={}, geofences: {})

  if h[:name] then
    puts ('geofences2: ' + geofences.inspect)
    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

Instance Method Details

#to_sObject



2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
# File 'lib/ruby-macrodroid.rb', line 2028

def to_s()
  
  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