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
: () -> String.
-
#initialize(move_x:, move_y:) ⇒ Direction
constructor
: (move_x: Integer | Float, move_y: Integer | Float) -> void.
-
#to_s ⇒ Object
: () -> String.
Constructor Details
#initialize(move_x:, move_y:) ⇒ Direction
: (move_x: Integer | Float, move_y: Integer | Float) -> void
145 146 147 148 |
# File 'lib/fusuma/plugin/detectors/swipe_detector.rb', line 145 def initialize(move_x:, move_y:) @move_x = move_x.to_f @move_y = move_y.to_f end |
Instance Method Details
#calc ⇒ Object
: () -> String
156 157 158 159 160 161 162 163 164 |
# File 'lib/fusuma/plugin/detectors/swipe_detector.rb', line 156 def calc if @move_x.abs > @move_y.abs @move_x.positive? ? RIGHT : LEFT elsif @move_y.positive? DOWN else UP end end |
#to_s ⇒ Object
: () -> String
151 152 153 |
# File 'lib/fusuma/plugin/detectors/swipe_detector.rb', line 151 def to_s calc end |