Method: Enumerable#transitive_closure
- Defined in:
- lib/jinx/helpers/transitive_closure.rb
#transitive_closure(method = nil) ⇒ Object
Returns the transitive closure over all items in this Enumerable.
45 46 47 48 49 50 51 52 |
# File 'lib/jinx/helpers/transitive_closure.rb', line 45 def transitive_closure(method=nil) # delegate to Object if there is a method argument return super(method) if method # this Enumerable's children are this Enumerable's contents closure = super() { |node| node.equal?(self) ? self : yield(node) } # remove this collection from the closure closure[1..-1] end |