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.



1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
# File 'lib/ruby-macrodroid/triggers.rb', line 1318

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



1331
1332
1333
1334
# File 'lib/ruby-macrodroid/triggers.rb', line 1331

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

#to_summary(colour: false) ⇒ Object



1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
# File 'lib/ruby-macrodroid/triggers.rb', line 1336

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