Class: GeofenceTrigger
- Inherits:
-
Trigger
- Object
- MacroObject
- Trigger
- GeofenceTrigger
- Defined in:
- lib/ruby-macrodroid.rb
Overview
Category: Location
Instance Attribute Summary
Attributes inherited from MacroObject
Instance Method Summary collapse
-
#initialize(h = {}, geofences: {}) ⇒ GeofenceTrigger
constructor
A new instance of GeofenceTrigger.
- #to_s ⇒ Object
Methods inherited from Trigger
Methods inherited from MacroObject
Constructor Details
#initialize(h = {}, geofences: {}) ⇒ GeofenceTrigger
Returns a new instance of GeofenceTrigger.
1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 |
# File 'lib/ruby-macrodroid.rb', line 1952 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 = { update_rate_text: '5 Minutes', geofence_id: '', geofence_update_rate_minutes: 5, trigger_from_unknown: false, enter_area: true } super(.merge filter(, h)) @geofences = geofences end |
Instance Method Details
#to_s ⇒ Object
1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 |
# File 'lib/ruby-macrodroid.rb', line 1974 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 label = found ? found.name : 'error: name not found' "Geofence %s (%s)" % [direction, label] end |