Class: EventMachine::Stdout

Inherits:
Connection
  • Object
show all
Defined in:
lib/em/stdout.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#stdoutObject

Returns the value of attribute stdout.



31
32
33
# File 'lib/em/stdout.rb', line 31

def stdout
  @stdout
end

Class Method Details

.outputObject



22
23
24
# File 'lib/em/stdout.rb', line 22

def output
  defined?(@@output) ? @@output : @@output = true
end

.output=(output) ⇒ Object



26
27
28
# File 'lib/em/stdout.rb', line 26

def output=(output)
  @@output = output
end

Instance Method Details

#callback(&block) ⇒ Object



33
34
35
# File 'lib/em/stdout.rb', line 33

def callback(&block)
  @callback = block
end

#receive_data(data) ⇒ Object



37
38
39
40
# File 'lib/em/stdout.rb', line 37

def receive_data(data)
  stdout.print(data) if self.class.output
  @callback.call(data) if @callback
end

#unbindObject



42
43
44
# File 'lib/em/stdout.rb', line 42

def unbind
  STDOUT.reopen(stdout)
end