Class: Pry::Pager

Inherits:
Object show all
Defined in:
lib/pry/pager.rb

Defined Under Namespace

Classes: NullPager, PageTracker, SimplePager, StopPaging, SystemPager

Instance Attribute Summary collapse

Instance Method Summary collapse

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_instanceObject (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

#openObject

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.

Parameters:

  • text (String)

    Text to run through a pager.



25
26
27
28
29
# File 'lib/pry/pager.rb', line 25

def page(text)
  open do |pager|
    pager << text
  end
end