class Enumex::Base
Attributes
block[R]
enumerator[R]
Public Instance Methods
attach_to(enumerator, &block)
click to toggle source
# File lib/enumex/base.rb, line 5 def attach_to(enumerator, &block) raise TypeError unless enumerator.is_a?(Enumerator) @enumerator = enumerator @block = block actions.empty? ? self : run end
Private Instance Methods
actions()
click to toggle source
# File lib/enumex/base.rb, line 22 def actions @actions ||= ActionContainers.new(self) end
new_enumerator()
click to toggle source
# File lib/enumex/base.rb, line 33 def new_enumerator Enumerator.new do |y| actions.reset enumerator.each do |*args| actions.pre.extenders.each {|e| e.execute(*args) } result = y.yield(*args) actions.post.extenders.each {|e| e.execute(*args) } result end end end
run()
click to toggle source
# File lib/enumex/base.rb, line 26 def run return unless enumerator enm = new_enumerator block ? enm.each(&block) : enm end