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.



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

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

Instance Method Details

#each(rs = nil) ⇒ Object



138
139
140
141
142
143
144
145
# File 'lib/shell/builtin-command.rb', line 138

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