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 Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(primary, secondary) ⇒ TeeIO
Returns a new instance of TeeIO.
8
9
10
11
|
# File 'lib/console_agent/executor.rb', line 8
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
38
39
40
|
# File 'lib/console_agent/executor.rb', line 38
def method_missing(method, *args, &block)
@primary.send(method, *args, &block)
end
|
Instance Attribute Details
#secondary ⇒ Object
Returns the value of attribute secondary.
6
7
8
|
# File 'lib/console_agent/executor.rb', line 6
def secondary
@secondary
end
|
Instance Method Details
#flush ⇒ Object
30
31
32
|
# File 'lib/console_agent/executor.rb', line 30
def flush
@primary.flush if @primary.respond_to?(:flush)
end
|
#print(*args) ⇒ Object
25
26
27
28
|
# File 'lib/console_agent/executor.rb', line 25
def print(*args)
@primary.print(*args)
args.each { |a| @secondary.write(a.to_s) }
end
|
#puts(*args) ⇒ Object
18
19
20
21
22
23
|
# File 'lib/console_agent/executor.rb', line 18
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
34
35
36
|
# File 'lib/console_agent/executor.rb', line 34
def respond_to_missing?(method, include_private = false)
@primary.respond_to?(method, include_private) || super
end
|
#write(str) ⇒ Object
13
14
15
16
|
# File 'lib/console_agent/executor.rb', line 13
def write(str)
@primary.write(str)
@secondary.write(str)
end
|