In Files
- shell/filter.rb
Parent
Object
Included Modules
- Enumerable
Shell::Filter
Any result of command execution is a Filter.
This class includes Enumerable, therefore a Filter object can use all Enumerable facilities.
Public Class Methods
Public Instance Methods
filter1 + filter2
Outputs filter1
, and then filter2
using Join.new
# File shell/filter.rb, line 114 def + (filter) Join.new(@shell, self, filter) end
< source
Inputs from source
, which is either a string of a file name or
an IO object.
# File shell/filter.rb, line 50 def < (src) case src when String cat = Cat.new(@shell, src) cat | self when IO self.input = src self else Shell.Fail Error::CantApplyMethod, "<", to.class end end
> source
Outputs from source
, which is either a string of a file name
or an IO object.
# File shell/filter.rb, line 68 def > (to) case to when String dst = @shell.open(to, "w") begin each(){|l| dst << l} ensure dst.close end when IO each(){|l| to << l} else Shell.Fail Error::CantApplyMethod, ">", to.class end self end
>> source
Appends the output to source
, which is either a string of a
file name or an IO object.
# File shell/filter.rb, line 90 def >> (to) begin Shell.cd(@shell.pwd).append(to, self) rescue CantApplyMethod Shell.Fail Error::CantApplyMethod, ">>", to.class end end
each(record_separator=nil) { block }
Iterates a block for each line.
# File shell/filter.rb, line 38 def each(rs = nil) rs = @shell.record_separator unless rs if @input @input.each(rs){|l| yield l} end end