Recursor “functor”.
NOTE: THIS IS A WORK IN PROGRESS!
Recursive iteration over enumerables.
[1, 2, [3, 4]].recursive.each{ |e| p e }
produces
1 2 3 4
NOTE: Technically this should check for the proper conversion method if applicable, eg. # for Array, rather than just checking the class type. In the future this may be generally supported if Facets ever adds a “class know-thy-self” library. In the meantime override in classes are required to incorporate this.
# File lib/core/facets/enumerable/recursive.rb, line 36 36: def each(&b) 37: @enum.each{ |*v| process(:each, *v, &b) } 38: end
# File lib/core/facets/enumerable/recursive.rb, line 57 57: def process(op, v, &b) 58: case v 59: when String # b/c of 1.8 60: b.call(v) 61: when @enum.class 62: v.recursive(@opts).send(op,&b) 63: else 64: #if @opts[:skip] && Enumerable === v 65: # v 66: #else 67: b.call(v) 68: #end 69: end 70: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.