Class: ActivityRecognitionTrigger

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

Overview

Category: Sensors

Instance Attribute Summary

Attributes inherited from Trigger

#constraints

Attributes inherited from MacroObject

#options, #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.



2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
# File 'lib/ruby-macrodroid.rb', line 2149

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_sObject



2162
2163
2164
2165
# File 'lib/ruby-macrodroid.rb', line 2162

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

#to_summaryObject



2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
# File 'lib/ruby-macrodroid.rb', line 2167

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