Class: NREPL::FakeStdout

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/nrepl-lazuli/fake_stdout.rb

Instance Method Summary collapse

Constructor Details

#initialize(connections, io, kind) ⇒ FakeStdout

Returns a new instance of FakeStdout.



5
6
7
8
9
10
# File 'lib/nrepl-lazuli/fake_stdout.rb', line 5

def initialize(connections, io, kind)
  @connections = connections
  @io = io
  @kind = kind
  super(io)
end

Instance Method Details

#<<(text) ⇒ Object



12
13
14
15
# File 'lib/nrepl-lazuli/fake_stdout.rb', line 12

def <<(text)
  print(text)
  nil
end


17
18
19
20
# File 'lib/nrepl-lazuli/fake_stdout.rb', line 17

def print(*text)
  write(text.join(''))
  nil
end

#puts(*text) ⇒ Object



22
23
24
25
# File 'lib/nrepl-lazuli/fake_stdout.rb', line 22

def puts(*text)
  write("#{text.join("\n")}\n")
  nil
end

#write(*texts) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/nrepl-lazuli/fake_stdout.rb', line 27

def write(*texts)
  text = texts.join('')
  @connections.each do |conn|
    conn.send_msg(
      @kind => text
    )
  end
  @io.write(text)
end