class Lazily::Filter

def each

def each
  return to_enum unless block_given?
  yielder = proc { |x| yield x }
  if @generator.arity == 2
    # we might want to terminate early
    all_done = "Lazily::loop-done-#{object_id}".to_sym
    catch all_done do
      @generator.call(yielder, all_done)
    end
  else
    @generator.call(yielder)
  end
end

def initialize(source, method, &generator)

def initialize(source, method, &generator)
  @source = source
  @method = method
  @generator = generator
end

def inspect

def inspect
  "#<#{self.class}: #{@method} #{@source.inspect}>"
end