class Pry::Pager
Attributes
Public Class Methods
# File lib/pry/pager.rb, line 13 def initialize(pry_instance) @pry_instance = pry_instance end
Public Instance Methods
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 # rubocop:disable Lint/HandleExceptions ensure pager.close if pager end
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
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 56 def best_available if !pry_instance.config.pager NullPager.new(pry_instance.output) elsif !SystemPager.available? || Helpers::Platform.jruby? SimplePager.new(pry_instance.output) else SystemPager.new(pry_instance.output) end end
# File lib/pry/pager.rb, line 43 def enabled? !!@enabled end