Class Shell::Filter
In: shell/filter.rb
Parent: Object

Filter A method to require

   each()

Methods

+   <   >   >>   each   input=   inspect   new   to_a   to_s   |  

Included Modules

Enumerable

Attributes

input  [R] 

Public Class methods

[Source]

# File shell/filter.rb, line 22
    def initialize(sh)
      @shell = sh         # parent shell
      @input = nil        # input filter
    end

Public Instance methods

[Source]

# File shell/filter.rb, line 86
    def + (filter)
      Join.new(@shell, self, filter)
    end

[Source]

# File shell/filter.rb, line 40
    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]

# File shell/filter.rb, line 53
    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]

# File shell/filter.rb, line 70
    def >> (to)
      begin
        Shell.cd(@shell.pwd).append(to, self)
      rescue CantApplyMethod
        Shell.Fail Error::CantApplyMethod, ">>", to.class
      end
    end

[Source]

# File shell/filter.rb, line 33
    def each(rs = nil)
      rs = @shell.record_separator unless rs
      if @input
        @input.each(rs){|l| yield l}
      end
    end

[Source]

# File shell/filter.rb, line 29
    def input=(filter)
      @input = filter
    end

[Source]

# File shell/filter.rb, line 102
    def inspect
      if @shell.debug.kind_of?(Integer) && @shell.debug > 2
        super
      else
        to_s
      end
    end

[Source]

# File shell/filter.rb, line 90
    def to_a
      ary = []
      each(){|l| ary.push l}
      ary
    end

[Source]

# File shell/filter.rb, line 96
    def to_s
      str = ""
      each(){|l| str.concat l}
      str
    end

[Source]

# File shell/filter.rb, line 78
    def | (filter)
      filter.input = self
      if active?
        @shell.process_controller.start_job filter
      end
      filter
    end

[Validate]

ruby-doc.org is a community service provided by James Britt and Happy Camper Studios, a Phoenix, Arizona, Ruby application development company.

Documentation content on ruby-doc.org is provided by remarkable members of the Ruby community.

For more information on the Ruby programming language, visit ruby-lang.org.

Want to help improve Ruby's API docs? See Ruby Documentation Guidelines.