Parent

Class/Module Index [+]

Quicksearch

Rabbit::Gesture::Processor

Attributes

motions[R]
skew_threshold_angle[RW]
threshold[RW]

Public Class Methods

new(threshold=nil, skew_threshold_angle=nil) click to toggle source
# File lib/rabbit/gesture/processor.rb, line 10
def initialize(threshold=nil, skew_threshold_angle=nil)
  @threshold = threshold || DEFAULT_THRESHOLD
  @skew_threshold_angle = skew_threshold_angle
  @skew_threshold_angle ||= DEFAULT_SKEW_THRESHOLD_ANGLE
  reset
end

Public Instance Methods

available_motion?(motion) click to toggle source
# File lib/rabbit/gesture/processor.rb, line 23
def available_motion?(motion)
  MOTIONS.include?(motion)
end
position() click to toggle source
# File lib/rabbit/gesture/processor.rb, line 63
def position
  [@x, @y]
end
reset() click to toggle source
# File lib/rabbit/gesture/processor.rb, line 53
def reset
  @started = false
  @x = @y = -1
  @motions = []
end
start(x, y) click to toggle source
# File lib/rabbit/gesture/processor.rb, line 27
def start(x, y)
  @prev_x = @x = x
  @prev_y = @y = y
  @started = true
  @motions = []
end
started?() click to toggle source
# File lib/rabbit/gesture/processor.rb, line 17
def started?
  @started
end
to_a() click to toggle source
# File lib/rabbit/gesture/processor.rb, line 59
def to_a
  @motions
end
update_position(x, y) click to toggle source
# File lib/rabbit/gesture/processor.rb, line 34
def update_position(x, y)
  mx = x - @prev_x
  my = y - @prev_y

  motion = judge_motion(mx, my)
  if motion
    @prev_x = @x = x
    @prev_y = @y = y
    if @motions.last == motion
      false
    else
      @motions << motion
      true
    end
  else
    false
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.