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.
- #match?(detail = {}) ⇒ Boolean
- #to_s(colour: false) ⇒ Object
- #to_summary(colour: false) ⇒ Object
Methods inherited from MacroObject
Constructor Details
#initialize(obj = nil) ⇒ ActivityRecognitionTrigger
Returns a new instance of ActivityRecognitionTrigger.
1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 |
# 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 = { confidence_level: 50, selected_index: 1 } super(.merge h) @activity = ['In Vehicle', 'On Bicycle', 'Running', 'Walking', 'Still'] end |
Instance Method Details
#match?(detail = {}) ⇒ Boolean
1423 1424 1425 |
# File 'lib/ruby-macrodroid/triggers.rb', line 1423 def match?(detail={}) @h[:selected_index] == detail[:selected_index] end |
#to_s(colour: false) ⇒ Object
1427 1428 1429 1430 1431 1432 1433 1434 1435 |
# 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) ⇒ Object
1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 |
# 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 |