Class: TTY::Pager::SystemPager::PagerIO Private

Inherits:
Object
  • Object
show all
Defined in:
lib/tty/pager/system.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A wrapper for an external process.

Instance Method Summary collapse

Constructor Details

#initialize(command) ⇒ PagerIO

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of PagerIO.


214
215
216
217
218
# File 'lib/tty/pager/system.rb', line 214

def initialize(command)
  @command = command
  @io      = IO.popen(@command, "w")
  @pid     = @io.pid
end

Instance Method Details

#closeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


228
229
230
231
232
233
234
235
236
237
238
# File 'lib/tty/pager/system.rb', line 228

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) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


224
225
226
# File 'lib/tty/pager/system.rb', line 224

def puts(*args)
  io_call(:puts, *args)
end

#write(*args) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


220
221
222
# File 'lib/tty/pager/system.rb', line 220

def write(*args)
  io_call(:write, *args)
end