Class: ActivityRecognitionTrigger

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

Overview

Category: Sensors

Instance Attribute Summary

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.



2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
# File 'lib/ruby-macrodroid.rb', line 2079

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



2092
2093
2094
2095
# File 'lib/ruby-macrodroid.rb', line 2092

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

#to_summaryObject



2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
# File 'lib/ruby-macrodroid.rb', line 2097

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