Class: Shell::Filter
| Relationships & Source Files | |
| Extension / Inclusion / Inheritance Descendants | |
| Subclasses: | |
| Super Chains via Extension / Inclusion / Inheritance | |
| Instance Chain: 
          self,
          Enumerable
         | |
| Inherits: | Object | 
| Defined in: | lib/shell/filter.rb | 
Overview
Any result of command execution is a Filter.
This class includes Enumerable, therefore a Filter object can use all Enumerable facilities.
Class Method Summary
- .new(sh) ⇒ Filter constructor
Instance Attribute Summary
- #input rw
- #input=(filter) rw
Instance Method Summary
- 
    
      #+(filter2)  
    
    Outputs filter1, and thenfilter2usingJoin.new
- 
    
      #<(source)  
    
    Inputs from source, which is either a string of a file name or an IO object.
- 
    
      #>(source)  
    
    Outputs from source, which is either a string of a file name or an IO object.
- 
    
      #>>(source)  
    
    Appends the output to source, which is either a string of a file name or an IO object.
- 
    
      #each(record_separator = nil)  
      (also: #super_each)
    
    Iterates a block for each line. 
- #inspect
- #to_a
- #to_s
- 
    
      #|(filter)  
    
    Processes a pipeline. 
Constructor Details
    .new(sh)  ⇒ Filter 
  
# File 'lib/shell/filter.rb', line 23
def initialize(sh) @shell = sh # parent shell @input = nil # input filter end
Instance Attribute Details
#input (rw)
[ GitHub ]# File 'lib/shell/filter.rb', line 28
attr_reader :input
#input=(filter) (rw)
[ GitHub ]# File 'lib/shell/filter.rb', line 30
def input=(filter) @input = filter end
Instance Method Details
#+(filter2)
Outputs filter1, and then filter2 using Join.new
# File 'lib/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.
#>(source)
Outputs from source, which is either a string of a file name or an IO object.
#>>(source)
Appends the output to source, which is either a string of a file name or an IO object.
#each(record_separator = nil) Also known as: #super_each
Iterates a block for each line.
# File 'lib/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
#inspect
[ GitHub ]#to_a
[ GitHub ]# File 'lib/shell/filter.rb', line 118
def to_a ary = [] each(){|l| ary.push l} ary end
#to_s
[ GitHub ]# File 'lib/shell/filter.rb', line 124
def to_s str = "" each(){|l| str.concat l} str end
#|(filter)
Processes a pipeline.
# File 'lib/shell/filter.rb', line 102
def |(filter) filter.input = self if active? @shell.process_controller.start_job filter end filter end