class Pry::Pager

Attributes

_pry_[R]

Public Class Methods

new(_pry_) click to toggle source
# File lib/pry/pager.rb, line 13
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 `#<<`.

# File lib/pry/pager.rb, line 33
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

Text to run through a pager.
# File lib/pry/pager.rb, line 25
def page(text)
  open do |pager|
    pager << text
  end
end

Private Instance Methods

best_available() click to toggle source

Return an instance of the “best” available pager class – `SystemPager` if possible, `SimplePager` if `SystemPager` isn't available, and `NullPager` if the user has disabled paging. All pagers accept output with `#puts`, `#print`, `#write`, and `#<<`. You must call `#close` when you're done writing output to a pager, and you must rescue `Pry::Pager::StopPaging`. These requirements can be avoided by using `.open` instead.

# File lib/pry/pager.rb, line 54
def best_available
  if !_pry_.config.pager
    NullPager.new(_pry_.output)
  elsif !SystemPager.available? || Helpers::Platform.jruby?
    SimplePager.new(_pry_.output)
  else
    SystemPager.new(_pry_.output)
  end
end
enabled?() click to toggle source
# File lib/pry/pager.rb, line 43
def enabled?; !!@enabled; end
output() click to toggle source
# File lib/pry/pager.rb, line 45
def output; @output; end