Class: ProximityTrigger
- Inherits:
-
SensorsTrigger
- Object
- MacroObject
- Trigger
- SensorsTrigger
- ProximityTrigger
- 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) ⇒ ProximityTrigger
constructor
A new instance of ProximityTrigger.
- #match?(detail = {}, model = nil) ⇒ Boolean
- #to_s(colour: false) ⇒ Object (also: #to_summary)
Methods inherited from MacroObject
Constructor Details
#initialize(obj = nil) ⇒ ProximityTrigger
Returns a new instance of ProximityTrigger.
1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 |
# File 'lib/ruby-macrodroid/triggers.rb', line 1452 def initialize(obj=nil) h = if obj.is_a? Hash then obj elsif obj.is_a? Array e, macro = obj txt = e.text('item/description') {option: (txt || e.text), macro: macro} end = { near: true, selected_option: 0 } if h[:distance] then case h[:distance].to_sym when :near [:near] = true end end super(.merge h) end |
Instance Method Details
#match?(detail = {}, model = nil) ⇒ Boolean
1479 1480 1481 |
# File 'lib/ruby-macrodroid/triggers.rb', line 1479 def match?(detail={}, model=nil) @h[:selected_option] == detail[:option].to_i end |
#to_s(colour: false) ⇒ Object Also known as: to_summary
1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 |
# File 'lib/ruby-macrodroid/triggers.rb', line 1483 def to_s(colour: false) distance = if @h[:near] then 'Near' else 'Far' end @s = "Proximity Sensor (%s)" % distance super() end |