Class: Shell::Tee

Inherits:
BuiltInCommand show all
Defined in:
lib/shell/builtin-command.rb

Instance Attribute Summary

Attributes inherited from Filter

#input

Instance Method Summary collapse

Methods inherited from BuiltInCommand

#active?, #wait?

Methods inherited from Filter

#+, #<, #>, #>>, #inspect, #to_a, #to_s, #|

Constructor Details

#initialize(sh, filename) ⇒ Tee

Returns a new instance of Tee.



127
128
129
130
# File 'lib/shell/builtin-command.rb', line 127

def initialize(sh, filename)
  super sh
  @to_filename = filename
end

Instance Method Details

#each(rs = nil) ⇒ Object



132
133
134
135
136
137
138
139
# File 'lib/shell/builtin-command.rb', line 132

def each(rs = nil)
  to = @shell.open(@to_filename, "w")
  begin
	super{|l| to << l; yield l}
  ensure
	to.close
  end
end