Extended maintenance of Ruby versions 1.8.7 and 1.9.2 will end on July 31, 2014. Read more

In Files

  • shell/filter.rb

Parent

Included Modules

Shell::Filter

Filter A method to require

each()

Attributes

input[R]

Public Class Methods

new(sh) click to toggle source
 
               # File shell/filter.rb, line 21
def initialize(sh)
  @shell = sh         # parent shell
  @input = nil        # input filter
end
            

Public Instance Methods

+(filter) click to toggle source
 
               # File shell/filter.rb, line 85
def + (filter)
  Join.new(@shell, self, filter)
end
            
<(src) click to toggle source
 
               # File shell/filter.rb, line 39
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
            
>(to) click to toggle source
 
               # File shell/filter.rb, line 52
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
            
>>(to) click to toggle source
 
               # File shell/filter.rb, line 69
def >> (to)
  begin
    Shell.cd(@shell.pwd).append(to, self)
  rescue CantApplyMethod
    Shell.Fail Error::CantApplyMethod, ">>", to.class
  end
end
            
each(rs = nil) click to toggle source
 
               # File shell/filter.rb, line 32
def each(rs = nil)
  rs = @shell.record_separator unless rs
  if @input
    @input.each(rs){|l| yield l}
  end
end
            
input=(filter) click to toggle source
 
               # File shell/filter.rb, line 28
def input=(filter)
  @input = filter
end
            
inspect() click to toggle source
 
               # File shell/filter.rb, line 101
def inspect
  if @shell.debug.kind_of?(Integer) && @shell.debug > 2
    super
  else
    to_s
  end
end
            
to_a() click to toggle source
 
               # File shell/filter.rb, line 89
def to_a
  ary = []
  each(){|l| ary.push l}
  ary
end
            
to_s() click to toggle source
 
               # File shell/filter.rb, line 95
def to_s
  str = ""
  each(){|l| str.concat l}
  str
end
            
|(filter) click to toggle source
 
               # File shell/filter.rb, line 77
def | (filter)
  filter.input = self
  if active?
    @shell.process_controller.start_job filter
  end
  filter
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus