# class Enumerable::Recursor

Recursor is a specialized Functor for recurively iterating over Enumerables.

### Public Class Methods

new(enum, *types, &block) click to toggle source

    # File lib/facets/enumerable/recursively.rb, line 20
    def initialize(enum, *types, &block)
      @enum   = enum
      @types  = types.empty? ? [@enum.class] : types
      @block  = block
    end

### Public Instance Methods

method_missing(op, &yld) click to toggle source

    # File lib/facets/enumerable/recursively.rb, line 26
    def method_missing(op, &yld)
      rec = @block || lambda{ |v| v }
      yld = yld    || lambda{ |v| v }  # ? to_enum
      @enum.__send__(op) do |v|
        case v
        when String # b/c of 1.8
          yld.call(v)
        when *@types
          res = v.recursively(*@types, &@block).__send__(op,&yld)
          rec.call(res)
        else
          yld.call(v)
        end
      end
    end