Class: Functional::BottomUp

Inherits:
Base show all
Defined in:
lib/functional.rb

Instance Attribute Summary

Attributes inherited from Base

#exe, #next

Instance Method Summary collapse

Methods inherited from Base

#to_proc

Constructor Details

#initialize(start, *a, &e) ⇒ BottomUp

Returns a new instance of BottomUp.



78
79
80
81
# File 'lib/functional.rb', line 78

def initialize start, *a, &e
  @next.call *a, &e
  @buffer, @start = nil, start
end

Instance Method Details

#call(a) ⇒ Object



83
84
85
86
87
88
89
90
# File 'lib/functional.rb', line 83

def call a
  if @exe.call a
    @next.call @buffer+a
    @buffer = @start.dup
  else
    @buffer += a
  end
end

#endObject



92
93
94
95
# File 'lib/functional.rb', line 92

def end
  @next.call @buffer
  @next.end
end