Class: Pry::Pager::MindControlPager
- Inherits:
-
NullPager
- Object
- NullPager
- Pry::Pager::MindControlPager
- Defined in:
- lib/mind_control/pry_monkey_patches.rb
Overview
Custom SimplePager based pager that uses MindConrol’s IO (not host).
Instance Method Summary collapse
-
#initialize(input, output) ⇒ MindControlPager
constructor
A new instance of MindControlPager.
-
#write(str) ⇒ Object
Writes string to console with pagination.
Constructor Details
#initialize(input, output) ⇒ MindControlPager
Returns a new instance of MindControlPager.
25 26 27 28 29 30 |
# File 'lib/mind_control/pry_monkey_patches.rb', line 25 def initialize( input, output ) super( output ) @in = input @tracker = PageTracker.new( height - 3, width ) end |
Instance Method Details
#write(str) ⇒ Object
Writes string to console with pagination.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/mind_control/pry_monkey_patches.rb', line 36 def write( str ) str.lines.each do |line| @out.print line @tracker.record line if @tracker.page? @out.print "\n" @out.print "\e[0m" @out.print "<page break> --- Press enter to continue " \ "( q<enter> to break ) --- <page break>\n" raise StopPaging if @in.readline( "" ).chomp == "q" @tracker.reset end end end |