Class: Fusuma::Plugin::Detectors::SwipeDetector::Direction
- Inherits:
-
Object
- Object
- Fusuma::Plugin::Detectors::SwipeDetector::Direction
- Defined in:
- lib/fusuma/plugin/detectors/swipe_detector.rb
Overview
direction of gesture
Constant Summary collapse
- RIGHT =
'right'- LEFT =
'left'- DOWN =
'down'- UP =
'up'
Instance Method Summary collapse
- #calc ⇒ Object
-
#initialize(move_x:, move_y:) ⇒ Direction
constructor
A new instance of Direction.
- #to_s ⇒ Object
Constructor Details
#initialize(move_x:, move_y:) ⇒ Direction
Returns a new instance of Direction.
107 108 109 110 |
# File 'lib/fusuma/plugin/detectors/swipe_detector.rb', line 107 def initialize(move_x:, move_y:) @move_x = move_x @move_y = move_y end |
Instance Method Details
#calc ⇒ Object
116 117 118 119 120 121 122 123 124 |
# File 'lib/fusuma/plugin/detectors/swipe_detector.rb', line 116 def calc if @move_x.abs > @move_y.abs @move_x > 0 ? RIGHT : LEFT elsif @move_y > 0 DOWN else UP end end |
#to_s ⇒ Object
112 113 114 |
# File 'lib/fusuma/plugin/detectors/swipe_detector.rb', line 112 def to_s calc end |