Class: Spectre::ClosureAction
- Inherits:
-
Object
- Object
- Spectre::ClosureAction
- Defined in:
- lib/spectre/generic/semanticaction.rb
Overview
This semantic action will be instantiated everytime a symbol is given to Parser#[]. It stores the value it receives inside the closure.
Instance Method Summary collapse
- #call(match, closure) ⇒ Object
-
#initialize(sym) ⇒ ClosureAction
constructor
sym
is the Symbol under which the parsed value will be stored in the Closure.
Constructor Details
#initialize(sym) ⇒ ClosureAction
sym
is the Symbol under which the parsed value will be stored in the Closure.
32 33 34 |
# File 'lib/spectre/generic/semanticaction.rb', line 32 def initialize sym @sym = sym end |
Instance Method Details
#call(match, closure) ⇒ Object
36 37 38 39 |
# File 'lib/spectre/generic/semanticaction.rb', line 36 def call match, closure raise "no closure set for ClosureAction" unless closure closure[@sym] = match.value end |