Class: Fusuma::GestureAction

Inherits:
Object
  • Object
show all
Defined in:
lib/fusuma/gesture_action.rb

Overview

pinch or swipe action

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time, action, finger, directions) ⇒ GestureAction

Returns a new instance of GestureAction.



4
5
6
7
8
9
10
11
# File 'lib/fusuma/gesture_action.rb', line 4

def initialize(time, action, finger, directions)
  @time   = time.to_f
  @action = action
  @finger = finger
  @move_x = directions[:move][:x].to_f
  @move_y = directions[:move][:y].to_f
  @zoom   = directions[:zoom].to_f
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



12
13
14
# File 'lib/fusuma/gesture_action.rb', line 12

def action
  @action
end

#fingerObject (readonly)

Returns the value of attribute finger.



12
13
14
# File 'lib/fusuma/gesture_action.rb', line 12

def finger
  @finger
end

#move_xObject (readonly)

Returns the value of attribute move_x.



12
13
14
# File 'lib/fusuma/gesture_action.rb', line 12

def move_x
  @move_x
end

#move_yObject (readonly)

Returns the value of attribute move_y.



12
13
14
# File 'lib/fusuma/gesture_action.rb', line 12

def move_y
  @move_y
end

#timeObject (readonly)

Returns the value of attribute time.



12
13
14
# File 'lib/fusuma/gesture_action.rb', line 12

def time
  @time
end

#zoomObject (readonly)

Returns the value of attribute zoom.



12
13
14
# File 'lib/fusuma/gesture_action.rb', line 12

def zoom
  @zoom
end

Class Method Details

.initialize_by(line, device_names) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fusuma/gesture_action.rb', line 16

def initialize_by(line, device_names)
  return if device_names.none? do |device_name|
    line.to_s =~ /^\s?#{device_name}/
  end
  return if line.to_s =~ /_BEGIN/
  return unless line.to_s =~ /GESTURE_SWIPE|GESTURE_PINCH/
  time, action, finger, directions = gesture_action_arguments(line)
  MultiLogger.debug(time: time, action: action,
                    finger: finger, directions: directions)
  GestureAction.new(time, action, finger, directions)
end