Class: SwipeTrigger
- Inherits:
-
Trigger
- Object
- MacroObject
- Trigger
- SwipeTrigger
- Defined in:
- lib/ruby-macrodroid/triggers.rb
Overview
Category: User Input
Instance Attribute Summary
Attributes inherited from Trigger
Attributes inherited from MacroObject
Instance Method Summary collapse
-
#initialize(obj = nil) ⇒ SwipeTrigger
constructor
A new instance of SwipeTrigger.
- #to_s(colour: false) ⇒ Object (also: #to_summary)
Methods inherited from Trigger
Methods inherited from MacroObject
Constructor Details
#initialize(obj = nil) ⇒ SwipeTrigger
Returns a new instance of SwipeTrigger.
1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 |
# File 'lib/ruby-macrodroid/triggers.rb', line 1749 def initialize(obj=nil) h = if obj.is_a? Hash then obj elsif obj.is_a? Array e, macro = obj s = e.text('item/description').to_s start, motion = s.split(/ - /,2) { swipe_start_area: ['Top Left', 'Top Right'].index(start), swipe_motion: %w(Across Diagonal Down).index(motion) } end = { swipe_start_area: 0, swipe_motion: 0, cleared: true } super(.merge h) end |
Instance Method Details
#to_s(colour: false) ⇒ Object Also known as: to_summary
1775 1776 1777 1778 1779 1780 1781 1782 |
# File 'lib/ruby-macrodroid/triggers.rb', line 1775 def to_s(colour: false) direction = [['Top Left', 'Top Right'][@h[:swipe_start_area]], %w(Across Diagonal Down)[@h[:swipe_motion]]].join(' - ') @s = 'Swipe Screen'# + @h.inspect @s += "\n" + direction super() end |