class Fusuma::Plugin::Filters::LibinputDeviceFilter::KeepDevice
Select Device
to keep
Attributes
from_option[R]
name_patterns[R]
Public Class Methods
from_option=(device)
click to toggle source
TODO: remove from_option
and command line options
# File lib/fusuma/plugin/filters/libinput_device_filter.rb, line 94 def from_option=(device) if device warn <<~COMMENT Don't use --device="Device name" option because it is deprecated. Use the options below instead. #{LibinputDeviceFilter.new.config_param_sample} COMMENT end @from_option = device end
new(name_patterns:)
click to toggle source
# File lib/fusuma/plugin/filters/libinput_device_filter.rb, line 52 def initialize(name_patterns:) @name_patterns = name_patterns | Array(self.class.from_option) end
Public Instance Methods
all()
click to toggle source
@return [Array]
# File lib/fusuma/plugin/filters/libinput_device_filter.rb, line 65 def all @all ||= if @name_patterns.empty? Device.available else Device.all.select do |device| match_pattern?(device.name) end end.tap do |devices| print_not_found_messages if devices.empty? end end
match_pattern?(string)
click to toggle source
@return [TrueClass] @return [FalseClass]
# File lib/fusuma/plugin/filters/libinput_device_filter.rb, line 84 def match_pattern?(string) return true if @name_patterns.empty? @name_patterns.any? { |name_pattern| string.match(name_pattern) } end
print_not_found_messages()
click to toggle source
# File lib/fusuma/plugin/filters/libinput_device_filter.rb, line 77 def print_not_found_messages puts 'Device is not found. Check following section on your config.yml' puts LibinputDeviceFilter.new.config_param_sample end
reset()
click to toggle source
remove cache for reloading new devices
# File lib/fusuma/plugin/filters/libinput_device_filter.rb, line 59 def reset @all = nil Device.reset end