class ActivityRecognitionTrigger
Category: Sensors
Public Class Methods
new(obj=nil)
click to toggle source
Calls superclass method
SensorsTrigger::new
# File lib/ruby-macrodroid/triggers.rb, line 1394 def initialize(obj=nil) #puts 'obj: ' + obj.inspect h = if obj.is_a? Hash then obj elsif obj.is_a? Array e, macro, h2 = obj #puts 'h2: ' + h2.inspect #puts 'e: ' + e.xml s = e.text('item/description').to_s #puts 's: ' + s.inspect {confidence_level: s[/\d+%$/].to_i}.merge h2 end options = { confidence_level: 50, selected_index: 1 } super(options.merge h) @activity = ['In Vehicle', 'On Bicycle', 'Running', 'Walking', 'Still'] end
Public Instance Methods
match?(detail={})
click to toggle source
# File lib/ruby-macrodroid/triggers.rb, line 1423 def match?(detail={}) @h[:selected_index] == detail[:selected_index] end
to_s(colour: false)
click to toggle source
Calls superclass method
Trigger#to_s
# File lib/ruby-macrodroid/triggers.rb, line 1427 def to_s(colour: false) activity = @activity[@h[:selected_index]] @s = 'Activity - ' + activity #+ @h.inspect @s += "\nConfidence >= %s%%" % @h[:confidence_level] super() end
to_summary(colour: false)
click to toggle source
# File lib/ruby-macrodroid/triggers.rb, line 1437 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