lib/fusuma/libinput_command.rb in fusuma-2.0.0.pre vs lib/fusuma/libinput_command.rb in fusuma-2.0.0.pre2
- old
+ new
@@ -28,27 +28,27 @@
# versiom_command prints "1.6.3\n"
@version ||= `#{version_command}`.strip
end
# @yieldparam [String] gives a line in libinput list-devices output to the block
- def list_devices
+ def list_devices(&block)
cmd = list_devices_command
MultiLogger.debug(list_devices: cmd)
p, i, o, e = POSIX::Spawn.popen4(cmd)
i.close
- o.each { |line| yield(line) }
+ o.each(&block)
ensure
[i, o, e].each { |io| io.close unless io.closed? }
Process.waitpid(p)
end
- # @return [String] return a latest line libinput debug-events
+ # @return [Integer, IO] return a latest line libinput debug-events
def debug_events
- @debug_events ||= begin
- _p, i, o, _e = POSIX::Spawn.popen4(debug_events_with_options)
- i.close
- o
- end
+ @debug_events = begin
+ p, i, o, _e = POSIX::Spawn.popen4(debug_events_with_options)
+ i.close
+ [p, o]
+ end
end
# @return [String] command
# @raise [SystemExit]
def version_command