Class: IO::CutInput
- Inherits:
-
InputFilter
- Object
- IO
- InputFilter
- IO::CutInput
- Defined in:
- lib/ttk/Tools/cut_output.rb
Instance Method Summary collapse
-
#initialize(io, lines = 10, column = 80) ⇒ CutInput
constructor
A new instance of CutInput.
Methods inherited from InputFilter
#each, #each_byte, #each_line, #getc, #gets, #read, #readlines
Methods inherited from IO
#compare_stream, dash, print_file, print_io, #testify, #to_diff_for_ttk_log, #to_s_for_ttk_log
Methods included from ImplIndent
Constructor Details
#initialize(io, lines = 10, column = 80) ⇒ CutInput
Returns a new instance of CutInput.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ttk/Tools/cut_output.rb', line 13 def initialize(io, lines=10, column=80) i = 0 super(io) do |line| if @input.closed? '' elsif i >= lines @input.close "...\n" else i += 1 line.length <= column ? line : (line[0..column].chomp + "\n") end end end |