Class: Fusuma::Plugin::Remap::DeviceMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/fusuma/plugin/remap/device_matcher.rb

Overview

Matches device names against device patterns defined in config

Instance Method Summary collapse

Constructor Details

#initializeDeviceMatcher

Returns a new instance of DeviceMatcher.



10
11
12
# File 'lib/fusuma/plugin/remap/device_matcher.rb', line 10

def initialize
  @patterns = nil
end

Instance Method Details

#match(device_name) ⇒ String?

Find matching device pattern for a device name

Parameters:

  • device_name (String)

    physical device name (e.g., “PFU HHKB-Hybrid”)

Returns:

  • (String, nil)

    matched pattern (e.g., “HHKB”), or nil if no match



17
18
19
20
21
# File 'lib/fusuma/plugin/remap/device_matcher.rb', line 17

def match(device_name)
  return nil if device_name.nil?

  patterns.find { |pattern| device_name =~ /#{pattern}/i }
end