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.
1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 |
# File 'lib/ruby-macrodroid/triggers.rb', line 1402 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
1429 1430 1431 |
# File 'lib/ruby-macrodroid/triggers.rb', line 1429 def match?(detail={}, model=nil) @h[:selected_option] == detail[:option].to_i end |
#to_s(colour: false) ⇒ Object Also known as: to_summary
1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 |
# File 'lib/ruby-macrodroid/triggers.rb', line 1433 def to_s(colour: false) distance = if @h[:near] then 'Near' else 'Far' end @s = "Proximity Sensor (%s)" % distance super() end |