Class: Fusuma::Swipe
- Inherits:
-
Object
- Object
- Fusuma::Swipe
- Defined in:
- lib/fusuma/swipe.rb
Overview
vector data
Constant Summary collapse
- BASE_THERESHOLD =
20
- BASE_INTERVAL =
0.5
Class Attribute Summary collapse
-
.last_time ⇒ Object
readonly
Returns the value of attribute last_time.
Instance Attribute Summary collapse
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Class Method Summary collapse
Instance Method Summary collapse
- #direction ⇒ Object
- #enough? ⇒ Boolean
-
#initialize(x, y) ⇒ Swipe
constructor
A new instance of Swipe.
Constructor Details
#initialize(x, y) ⇒ Swipe
Returns a new instance of Swipe.
7 8 9 10 |
# File 'lib/fusuma/swipe.rb', line 7 def initialize(x, y) @x = x @y = y end |
Class Attribute Details
.last_time ⇒ Object (readonly)
Returns the value of attribute last_time.
48 49 50 |
# File 'lib/fusuma/swipe.rb', line 48 def last_time @last_time end |
Instance Attribute Details
#x ⇒ Object (readonly)
Returns the value of attribute x.
11 12 13 |
# File 'lib/fusuma/swipe.rb', line 11 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
11 12 13 |
# File 'lib/fusuma/swipe.rb', line 11 def y @y end |
Class Method Details
.touch_last_time ⇒ Object
50 51 52 |
# File 'lib/fusuma/swipe.rb', line 50 def touch_last_time @last_time = Time.now end |
Instance Method Details
#direction ⇒ Object
13 14 15 16 |
# File 'lib/fusuma/swipe.rb', line 13 def direction return x > 0 ? 'right' : 'left' if x.abs > y.abs y > 0 ? 'down' : 'up' end |
#enough? ⇒ Boolean
18 19 20 21 |
# File 'lib/fusuma/swipe.rb', line 18 def enough? MultiLogger.debug(x: x, y: y) enough_distance? && enough_interval? && self.class.touch_last_time end |