lib/fusuma/device.rb in fusuma-1.2 vs lib/fusuma/device.rb in fusuma-1.2.1
- old
+ new
@@ -26,12 +26,10 @@
end
end
end
class << self
- attr_reader :given_devices
-
# @return [Array]
def all
@all ||= fetch_devices
end
@@ -51,42 +49,18 @@
def reset
@all = nil
@available = nil
end
- # Narrow down available device list
- # @param names [String, Array]
- def given_devices=(names)
- # NOTE: convert to Array
- device_names = Array(names)
- return if device_names.empty?
-
- @given_devices = narrow_available_devices(device_names: device_names)
- return unless @given_devices.empty?
-
- exit 1
- end
-
private
# @return [Array]
def fetch_devices
line_parser = LineParser.new
Plugin::Inputs::LibinputCommandInput.new.list_devices do |line|
line_parser.push(line)
end
line_parser.generate_devices
- end
-
- def narrow_available_devices(device_names:)
- device_names.select do |name|
- if available.map(&:name).include? name
- MultiLogger.info("Touchpad is found: #{name}")
- true
- else
- MultiLogger.warn("Touchpad is not found: #{name}")
- end
- end
end
# parse line and generate devices
class LineParser
attr_reader :lines