Class: ConsoleAgent::TeeIO
- Inherits:
-
Object
- Object
- ConsoleAgent::TeeIO
show all
- Defined in:
- lib/console_agent/executor.rb
Overview
Writes to two IO streams simultaneously
Instance Method Summary
collapse
Constructor Details
#initialize(primary, secondary) ⇒ TeeIO
Returns a new instance of TeeIO.
6
7
8
9
|
# File 'lib/console_agent/executor.rb', line 6
def initialize(primary, secondary)
@primary = primary
@secondary = secondary
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
36
37
38
|
# File 'lib/console_agent/executor.rb', line 36
def method_missing(method, *args, &block)
@primary.send(method, *args, &block)
end
|
Instance Method Details
#flush ⇒ Object
28
29
30
|
# File 'lib/console_agent/executor.rb', line 28
def flush
@primary.flush if @primary.respond_to?(:flush)
end
|
#print(*args) ⇒ Object
23
24
25
26
|
# File 'lib/console_agent/executor.rb', line 23
def print(*args)
@primary.print(*args)
args.each { |a| @secondary.write(a.to_s) }
end
|
#puts(*args) ⇒ Object
16
17
18
19
20
21
|
# File 'lib/console_agent/executor.rb', line 16
def puts(*args)
@primary.puts(*args)
args.each { |a| @secondary.write("#{a}\n") }
@secondary.write("\n") if args.empty?
end
|
#respond_to_missing?(method, include_private = false) ⇒ Boolean
32
33
34
|
# File 'lib/console_agent/executor.rb', line 32
def respond_to_missing?(method, include_private = false)
@primary.respond_to?(method, include_private) || super
end
|
#write(str) ⇒ Object
11
12
13
14
|
# File 'lib/console_agent/executor.rb', line 11
def write(str)
@primary.write(str)
@secondary.write(str)
end
|