Class: StringProcessing::Pipeline

Inherits:
Object
  • Object
show all
Defined in:
lib/string_processing.rb

Class Method Summary collapse

Class Method Details

.defineObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/string_processing.rb', line 6

def self.define
  b = Proc.new
  @@processors = []
  class_eval(&b)

  Class.new do
    @@using = @@processors

    def self.process *thing
      @@using.each{|x| thing = x.call(thing.flatten) }
      thing
    end

  end
end

.using(theblock) ⇒ Object



22
23
24
# File 'lib/string_processing.rb', line 22

def self.using theblock
  @@processors << theblock
end