class Pry::Pager

A pager is an `IO`-like object that accepts text and either prints it immediately, prints it one page at a time, or streams it to an external program to print one page at a time.

Attributes

_pry_[R]

Public Class Methods

new(_pry_) click to toggle source
# File lib/pry/pager.rb, line 12
def initialize(_pry_)
  @_pry_ = _pry_
end

Public Instance Methods

open() { |pager| ... } click to toggle source

Yields a pager object (`NullPager`, `SimplePager`, or `SystemPager`). All pagers accept output with `puts`, `print`, `write`, and `#<<`. @param [IO] output (`$stdout`) An object to send output to.

# File lib/pry/pager.rb, line 31
def open
  pager = best_available
  yield pager
rescue StopPaging
ensure
  pager.close if pager
end
page(text) click to toggle source

Send the given text through the best available pager (if `Pry.config.pager` is enabled). If you want to send text through in chunks as you generate it, use `open` to get a writable object instead. @param [String] text A piece of text to run through a pager. @param [IO] output (`$stdout`) An object to send output to.

# File lib/pry/pager.rb, line 22
def page(text)
  open do |pager|
    pager << text
  end
end