Class: GeofenceTrigger
- Inherits:
-
Trigger
- Object
- MacroObject
- Trigger
- GeofenceTrigger
- Defined in:
- lib/ruby-macrodroid/triggers.rb
Overview
Category: Location
Instance Attribute Summary
Attributes inherited from Trigger
Attributes inherited from MacroObject
Instance Method Summary collapse
-
#initialize(h = {}, geofences: {}) ⇒ GeofenceTrigger
constructor
A new instance of GeofenceTrigger.
- #to_s(colour: false) ⇒ Object
Methods inherited from Trigger
Methods inherited from MacroObject
Constructor Details
#initialize(h = {}, geofences: {}) ⇒ GeofenceTrigger
Returns a new instance of GeofenceTrigger.
1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 |
# File 'lib/ruby-macrodroid/triggers.rb', line 1290 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 = { 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(colour: false) ⇒ Object
1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 |
# File 'lib/ruby-macrodroid/triggers.rb', line 1312 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 |