Class: ActivityRecognitionTrigger
- Inherits:
-
SensorsTrigger
- Object
- MacroObject
- Trigger
- SensorsTrigger
- ActivityRecognitionTrigger
- Defined in:
- lib/ruby-macrodroid/triggers.rb
Overview
Category: Sensors
Instance Attribute Summary
Attributes inherited from Trigger
Attributes inherited from MacroObject
Instance Method Summary collapse
-
#initialize(obj = nil) ⇒ ActivityRecognitionTrigger
constructor
A new instance of ActivityRecognitionTrigger.
- #to_s(colour: false) ⇒ Object
- #to_summary(colour: false) ⇒ Object
Methods inherited from Trigger
Methods inherited from MacroObject
Constructor Details
#initialize(obj = nil) ⇒ ActivityRecognitionTrigger
Returns a new instance of ActivityRecognitionTrigger.
1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 |
# File 'lib/ruby-macrodroid/triggers.rb', line 1390 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 = { confidence_level: 50, selected_index: 1 } super(.merge h) @activity = ['In Vehicle', 'On Bicycle', 'Running', 'Walking', 'Still'] end |
Instance Method Details
#to_s(colour: false) ⇒ Object
1419 1420 1421 1422 1423 1424 1425 1426 1427 |
# File 'lib/ruby-macrodroid/triggers.rb', line 1419 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) ⇒ Object
1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 |
# File 'lib/ruby-macrodroid/triggers.rb', line 1429 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 |