class TouchscreenTaps::EventParser
Parses a raw line and creates an event object
Public Class Methods
call(event)
click to toggle source
# File lib/touchscreen_taps/event_parser.rb, line 7 def call(event) _device, event_name, _time, text = event.strip.split(nil, 4) Event.new(type(event_name), finger(text), *direction(text)) end
Private Class Methods
direction(text)
click to toggle source
# File lib/touchscreen_taps/event_parser.rb, line 14 def direction(text) return if text.nil? _finger, _finger2, x, y = text.tr('/|(|)', ' ').split [x, y] end
finger(text)
click to toggle source
# File lib/touchscreen_taps/event_parser.rb, line 25 def finger(text) return if text.nil? count, = text.split(nil, 3) count.to_i + 1 end
type(text)
click to toggle source
# File lib/touchscreen_taps/event_parser.rb, line 21 def type(text) text.split('_').last end