class Pry::Pager

Public Class Methods

new(text) click to toggle source
# File lib/pry/pager.rb, line 33
def initialize(text)
  @text = text
end
page(text, pager = nil) click to toggle source

@param [String] text

A piece of text to run through a pager.

@param [Symbol?] pager

`:simple` -- Use the pure ruby pager.
`:system` -- Use the system pager (less) or the environment variable
             $PAGER if set.
`nil`     -- Infer what pager to use from the environment.  What this
             really means is that JRuby and systems that do not have
             access to 'less' will run through the pure ruby pager.
# File lib/pry/pager.rb, line 11
def self.page(text, pager = nil)
  case pager
  when nil
    no_pager = !SystemPager.available?
    if no_pager || Pry::Helpers::BaseHelpers.jruby?
      SimplePager.new(text).page
    else
      SystemPager.new(text).page
    end
  when :simple
    SimplePager.new(text).page
  when :system
    SystemPager.new(text).page
  else
    raise "'#{pager}' is not a recognized pager."
  end
end
page_size() click to toggle source
# File lib/pry/pager.rb, line 29
def self.page_size
  @page_size ||= Pry::Terminal.height!
end