Parent

Included Modules

Files

LazyList::ListBuilder::ListBuilderProc

This class is a special kind of Proc object, that uses instance_eval to execute a code block.

Public Class Methods

new(lb, name, &block) click to toggle source

Creates a ListBuilderProc working on the list builder lb using the Proc returned by lb.#{name}. name has to be either :filter or :transform.

# File lib/lazylist/list_builder.rb, line 50
      def initialize(lb, name, &block)
        @name = name
        @lb = lb
        @method_missing_delegator = block_self(&block)
        super(&@lb.__send__(@name))
      end

Public Instance Methods

[](*args) click to toggle source

Alias for call

call(*args) click to toggle source

Call this ListBuilderProc instance with the arguments args, which have to be the ordered values of the variables.

# File lib/lazylist/list_builder.rb, line 59
      def call(*args)
        prepare_variables
        @lb.variables.each_with_index do |var, i|
          instance_variable_set "@#{var}", args[i]
        end
        instance_eval(&@lb.__send__(@name))
      end
Also aliased as: []

Private Instance Methods

prepare_variables() click to toggle source

(Not documented)

# File lib/lazylist/list_builder.rb, line 70
      def prepare_variables
        @variables_prepared and return
        variables = @lb.variables
        class << self; self; end.instance_eval do
          attr_reader(*variables)
        end
        @variables_prepared = true
      end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.