Class: LEAP::Motion::WS::Gesture

Inherits:
Object
  • Object
show all
Defined in:
lib/leap/motion/ws/gesture.rb

Overview

Recognized movement by the user

There is 4 Gesture subclasses :

Circle - A circular movement by a finger.
Swipe - A straight line movement by the hand with fingers extended.
KeyTap -  A downward tapping movement by a finger.
ScreenTap - A forward tapping movement by a finger.

Defined Under Namespace

Classes: Error

Class Method Summary collapse

Class Method Details

.list(data) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/leap/motion/ws/gesture.rb', line 15

def self.list(data)
  gestures = []
  if data["gestures"]
    data["gestures"].each do |gesture|
      gestures << make_gesture(gesture)
    end
  end
  return gestures
end

.make_gesture(data) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/leap/motion/ws/gesture.rb', line 25

def self.make_gesture(data)
  unless data.has_key? "type"
    raise Error, "gesture type unknown"
  end
  name = data["type"][0].upcase << data["type"][1..-1]
  unless class_exists?(name)
    raise Error, "gesture class `#{self}::#{name}' invalid"
  end
  const_get(name).new(data)
end