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.



221
222
223
224
225
# File 'lib/tty/pager/system.rb', line 221

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.



235
236
237
238
239
240
241
242
243
244
245
# 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) ⇒ 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.



231
232
233
# File 'lib/tty/pager/system.rb', line 231

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.



227
228
229
# File 'lib/tty/pager/system.rb', line 227

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