Class: ElasticTabstops::OutstreamToLines

Inherits:
Object
  • Object
show all
Defined in:
lib/elastic_tabstops/outstream_to_lines.rb

Instance Method Summary collapse

Constructor Details

#initialize(liner) ⇒ OutstreamToLines

INVARIANT: @text contains no newlines



8
9
10
11
# File 'lib/elastic_tabstops/outstream_to_lines.rb', line 8

def initialize(liner)
  @text = ''
  @liner = liner
end

Instance Method Details

#flushObject



34
35
36
37
# File 'lib/elastic_tabstops/outstream_to_lines.rb', line 34

def flush
  @liner.line(@text) unless @text.empty?
  @liner.line('') # signals end-of-input to the @liner
end


20
21
22
23
24
25
# File 'lib/elastic_tabstops/outstream_to_lines.rb', line 20

def print(*args)
  sio = StringIO.new
  result = sio.print(*args)
  add_text(sio.string)
  result
end

#puts(*args) ⇒ Object



13
14
15
16
17
18
# File 'lib/elastic_tabstops/outstream_to_lines.rb', line 13

def puts(*args)
  sio = StringIO.new
  result = sio.puts(*args)
  add_text(sio.string)
  result
end

#write(*args) ⇒ Object



27
28
29
30
31
32
# File 'lib/elastic_tabstops/outstream_to_lines.rb', line 27

def write(*args)
  sio = StringIO.new
  result = sio.write(*args)
  add_text(sio.string)
  result
end