Class: ActivityRecognitionTrigger

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

Overview

Category: Sensors

Instance Attribute Summary

Attributes inherited from Trigger

#constraints

Attributes inherited from MacroObject

#options, #siguid, #type

Instance Method Summary collapse

Methods inherited from Trigger

#match?

Methods inherited from MacroObject

#to_h

Constructor Details

#initialize(h = {}) ⇒ ActivityRecognitionTrigger

Returns a new instance of ActivityRecognitionTrigger.



1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
# File 'lib/ruby-macrodroid/triggers.rb', line 1365

def initialize(h={})

  options = {
    confidence_level: 50,
    selected_index: 1
  }

  super(options.merge h)
  
  @activity = ['In Vehicle', 'On Bicycle', 'Running', 'Walking', 'Still']    

end

Instance Method Details

#to_s(colour: false) ⇒ Object



1378
1379
1380
1381
# File 'lib/ruby-macrodroid/triggers.rb', line 1378

def to_s(colour: false)
  activity = @activity[@h[:selected_index]]
  'Activity - ' + activity
end

#to_summary(colour: false) ⇒ Object



1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
# File 'lib/ruby-macrodroid/triggers.rb', line 1383

def to_summary(colour: false)
  
  activity = @activity[@h[:selected_index]]
  s = if activity.length > 10 then
    activity[0..7] + '..'
  else
    activity
  end
  
  'Activity - ' + s
  
end