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(geofence, h = {}) ⇒ GeofenceTrigger

Returns a new instance of GeofenceTrigger.



1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
# File 'lib/ruby-macrodroid.rb', line 1884

def initialize(geofence, h={})

  if h[:name] then
    
    found = geofence.find {|x| x.name == h[:name]}
    h[:geofence_id] = found.id
    
  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))
  @geofence = geofence

end

Instance Method Details

#to_sObject



1906
1907
1908
1909
1910
1911
1912
# File 'lib/ruby-macrodroid.rb', line 1906

def to_s()
  
  puts ' @geofence: ' + @geofence.inspect if $debug   
  direction = @h[:enter_area] ? 'Entry' : 'Exit'
  "Geofence %s (%s)" % [direction, @geofence[@h[:geofence_id].to_sym].name]
  
end