class TTY::Pager::SystemPager::PagerIO
A wrapper for an external process.
@api private
Public Class Methods
new(command)
click to toggle source
# File lib/tty/pager/system.rb, line 221 def initialize(command) @command = command @io = IO.popen(@command, "w") @pid = @io.pid end
Public Instance Methods
close()
click to toggle source
# File lib/tty/pager/system.rb, line 235 def close return true if @io.closed? @io.close _, status = Process.waitpid2(@pid, Process::WNOHANG) status.success? rescue Errno::ECHILD, Errno::EPIPE # on jruby 9x waiting on pid raises ECHILD # on ruby 2.5/2.6, closing a closed pipe raises EPIPE true end
puts(*args)
click to toggle source
# File lib/tty/pager/system.rb, line 231 def puts(*args) io_call(:puts, *args) end
write(*args)
click to toggle source
# File lib/tty/pager/system.rb, line 227 def write(*args) io_call(:write, *args) end
Private Instance Methods
io_call(method_name, *args)
click to toggle source
# File lib/tty/pager/system.rb, line 249 def io_call(method_name, *args) @io.public_send(method_name, *args) rescue Errno::EPIPE raise PagerClosed.new("The pager process (`#{@command}`) was closed") end