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.
- #match?(detail = {}, model = nil) ⇒ Boolean
- #to_s(colour: false) ⇒ Object (also: #to_summary)
Methods inherited from MacroObject
Constructor Details
#initialize(obj = nil) ⇒ SwipeTrigger
Returns a new instance of SwipeTrigger.
1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 |
# File 'lib/ruby-macrodroid/triggers.rb', line 1766 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
#match?(detail = {}, model = nil) ⇒ Boolean
1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 |
# File 'lib/ruby-macrodroid/triggers.rb', line 1792 def match?(detail={}, model=nil) puts 'detail : ' + detail.inspect return false if detail.empty? detail[:swipe_start_area] = detail[:start] detail[:swipe_motion] = detail[:motion] return unless detail[:swipe_start_area] and detail[:swipe_motion] @h[:swipe_start_area] == detail[:swipe_start_area].to_i and \ @h[:swipe_motion] == detail[:swipe_motion].to_i end |
#to_s(colour: false) ⇒ Object Also known as: to_summary
1807 1808 1809 1810 1811 1812 1813 1814 |
# File 'lib/ruby-macrodroid/triggers.rb', line 1807 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 |