Class Shell::Filter
In: lib/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 lib/shell/filter.rb, line 22
22:     def initialize(sh)
23:       @shell = sh         # parent shell
24:       @input = nil        # input filter
25:     end

Public Instance methods

[Source]

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

[Source]

    # File lib/shell/filter.rb, line 40
40:     def < (src)
41:       case src
42:       when String
43:         cat = Cat.new(@shell, src)
44:         cat | self
45:       when IO
46:         self.input = src
47:         self
48:       else
49:         Shell.Fail Error::CantApplyMethod, "<", to.class
50:       end
51:     end

[Source]

    # File lib/shell/filter.rb, line 53
53:     def > (to)
54:       case to
55:       when String
56:         dst = @shell.open(to, "w")
57:         begin
58:           each(){|l| dst << l}
59:         ensure
60:           dst.close
61:         end
62:       when IO
63:         each(){|l| to << l}
64:       else
65:         Shell.Fail Error::CantApplyMethod, ">", to.class
66:       end
67:       self
68:     end

[Source]

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

[Source]

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

[Source]

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

[Source]

     # File lib/shell/filter.rb, line 102
102:     def inspect
103:       if @shell.debug.kind_of?(Integer) && @shell.debug > 2
104:         super
105:       else
106:         to_s
107:       end
108:     end

[Source]

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

[Source]

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

[Source]

    # File lib/shell/filter.rb, line 78
78:     def | (filter)
79:       filter.input = self
80:       if active?
81:         @shell.process_controller.start_job filter
82:       end
83:       filter
84:     end

[Validate]