Class: PauseOutput::OutputPager
- Defined in:
- lib/pause_output/output_pager.rb
Overview
A class to manage paged output.
Instance Method Summary collapse
-
#<<(obj) ⇒ Object
Write out an object as a string.
-
#initialize(options = {}) ⇒ OutputPager
constructor
Set up the initial values.
-
#write(str) ⇒ Object
Write out a general string with page pauses.
Constructor Details
#initialize(options = {}) ⇒ OutputPager
Set up the initial values.
11 12 13 14 15 |
# File 'lib/pause_output/output_pager.rb', line 11 def initialize(={}) @options = @lines = 0 @chars = 0 end |
Instance Method Details
#<<(obj) ⇒ Object
Write out an object as a string.
27 28 29 |
# File 'lib/pause_output/output_pager.rb', line 27 def <<(obj) write(obj.to_s) end |
#write(str) ⇒ Object
Write out a general string with page pauses.
18 19 20 21 22 23 24 |
# File 'lib/pause_output/output_pager.rb', line 18 def write(str) while !str.empty? pre,mid,str = str.partition("\n") write_str(pre) unless pre.empty? writeln unless mid.empty? end end |