Class: comcom::leapmotioncom::leapmotion::leap::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/reapmotion/core_ext/controller.rb

Constant Summary collapse

GESTURE_MAP =
{
  "swipe" => Gesture::Type::TYPE_SWIPE,
  "circle" => Gesture::Type::TYPE_CIRCLE,
  "screen_tap" => Gesture::Type::TYPE_SCREEN_TAP,
  "key_tap" => Gesture::Type::TYPE_KEY_TAP
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.run(*listeners) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/reapmotion/core_ext/controller.rb', line 21

def self.run(*listeners)
  controller = Controller.new
  listeners.each { |listener| controller.add_listener listener }
  yield
ensure
  listeners.each { |listener| controller.remove_listener listener }
end

Instance Method Details

#enable_gestures(*list) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/reapmotion/core_ext/controller.rb', line 11

def enable_gestures(*list)
  list.each do |sym|
    type = GESTURE_MAP[sym.to_s]
    
    raise TypeError.new("#{sym} is not a valid gesture type") unless type

    enable_gesture(type)
  end
end