Class: Pry::Pager
Defined Under Namespace
Classes: NullPager, PageTracker, SimplePager, StopPaging, SystemPager
Instance Attribute Summary collapse
-
#pry_instance ⇒ Object
readonly
Returns the value of attribute pry_instance.
Instance Method Summary collapse
-
#initialize(pry_instance) ⇒ Pager
constructor
A new instance of Pager.
-
#open ⇒ Object
Yields a pager object (
NullPager,SimplePager, orSystemPager). -
#page(text) ⇒ Object
Send the given text through the best available pager (if
Pry.config.pageris enabled).
Constructor Details
#initialize(pry_instance) ⇒ Pager
Returns a new instance of Pager.
13 14 15 |
# File 'lib/pry/pager.rb', line 13 def initialize(pry_instance) @pry_instance = pry_instance end |
Instance Attribute Details
#pry_instance ⇒ Object (readonly)
Returns the value of attribute pry_instance.
11 12 13 |
# File 'lib/pry/pager.rb', line 11 def pry_instance @pry_instance end |
Instance Method Details
#open ⇒ Object
Yields a pager object (NullPager, SimplePager, or SystemPager). All pagers accept output with #puts, #print, #write, and ‘#<<`.
33 34 35 36 37 38 39 |
# 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 |
#page(text) ⇒ Object
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.
25 26 27 28 29 |
# File 'lib/pry/pager.rb', line 25 def page(text) open do |pager| pager << text end end |