Class: ProconBypassMan::DeviceMouseFinder::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/procon_bypass_man/support/device_mouse_finder.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(shell_output) ⇒ Object



18
19
20
21
22
# File 'lib/procon_bypass_man/support/device_mouse_finder.rb', line 18

def self.parse(shell_output)
  instance = new
  instance.set_usb_devices_from(shell_output)
  instance
end

Instance Method Details

#set_usb_devices_from(shell_output) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/procon_bypass_man/support/device_mouse_finder.rb', line 24

def set_usb_devices_from(shell_output)
  @usb_devices =
    shell_output.split(/\n\n/).map do |text|
      display_name =  /N: Name="(.+?)"$/ =~ text && $1
      event_no = /H: Handlers=.*?(event\d).*?$/ =~ text && $1
      USBDevice.new(display_name, event_no)
    end
end

#usb_devicesObject



33
34
35
# File 'lib/procon_bypass_man/support/device_mouse_finder.rb', line 33

def usb_devices
  @usb_devices ||= []
end