Class: TextUtils::Pipe
- Inherits:
-
Object
- Object
- TextUtils::Pipe
- Defined in:
- lib/text_utils/pipe.rb
Instance Method Summary collapse
- #call(text) ⇒ Object
-
#initialize(*processors) ⇒ Pipe
constructor
A new instance of Pipe.
Constructor Details
#initialize(*processors) ⇒ Pipe
Returns a new instance of Pipe.
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/text_utils/pipe.rb', line 2 def initialize *processors @processor = processors.reverse.inject nil do |next_processor, | klass, args = if .is_a? Array [[0], [1..-1]] else [, []] end klass.new next_processor, *args end end |
Instance Method Details
#call(text) ⇒ Object
13 14 15 |
# File 'lib/text_utils/pipe.rb', line 13 def call text @processor.call text, {} end |