Class: Babl::Builder::BoundOperator

Inherits:
Object
  • Object
show all
Defined in:
lib/babl/builder/chain_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, &scope) ⇒ BoundOperator

Returns a new instance of BoundOperator.



71
72
73
74
# File 'lib/babl/builder/chain_builder.rb', line 71

def initialize(context, &scope)
    @context = context
    @scope = scope || :itself.to_proc
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



69
70
71
# File 'lib/babl/builder/chain_builder.rb', line 69

def context
  @context
end

Instance Method Details

#nest(context) ⇒ Object



80
81
82
# File 'lib/babl/builder/chain_builder.rb', line 80

def nest(context)
    self.class.new(context) { |node| scope[yield node] }
end

#precompile(node) ⇒ Object



76
77
78
# File 'lib/babl/builder/chain_builder.rb', line 76

def precompile(node)
    scope[node]
end