Class: NREPL::FakeStdout

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

Instance Method Summary collapse

Constructor Details

#initialize(connections, io, kind) ⇒ FakeStdout

Returns a new instance of FakeStdout.



3
4
5
6
7
# File 'lib/nrepl/fake_stdout.rb', line 3

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

Instance Method Details

#<<(text) ⇒ Object



9
10
11
# File 'lib/nrepl/fake_stdout.rb', line 9

def <<(text)
  print(text)
end

#closeObject



34
35
36
# File 'lib/nrepl/fake_stdout.rb', line 34

def close
  @io.close
end

#flushObject



30
31
32
# File 'lib/nrepl/fake_stdout.rb', line 30

def flush
  @io.flush
end


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

def print(text)
  write(text.to_s)
end

#puts(text) ⇒ Object



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

def puts(text)
  write("#{text}\n")
end

#syncObject



38
39
40
# File 'lib/nrepl/fake_stdout.rb', line 38

def sync
  @io.sync
end

#sync=(val) ⇒ Object



42
43
44
# File 'lib/nrepl/fake_stdout.rb', line 42

def sync=(val)
  @io.sync = val
end

#write(text) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/nrepl/fake_stdout.rb', line 21

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