Class: Predicate::Binder

Inherits:
Sexpr::Rewriter
  • Object
show all
Defined in:
lib/predicate/processors/binder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(binding) ⇒ Binder

Returns a new instance of Binder.



6
7
8
# File 'lib/predicate/processors/binder.rb', line 6

def initialize(binding)
  @binding = binding
end

Instance Attribute Details

#bindingObject (readonly)

Returns the value of attribute binding.



9
10
11
# File 'lib/predicate/processors/binder.rb', line 9

def binding
  @binding
end

Instance Method Details

#on_literal(sexpr) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/predicate/processors/binder.rb', line 11

def on_literal(sexpr)
  lit = sexpr.last
  if lit.is_a?(Placeholder)
    [:literal, binding[lit]]
  else
    sexpr
  end
end