class Calyx::Syntax::Unique
A type of production rule representing a unique substitution which only returns values that have not previously been selected. The probability that a given rule will be selected increases as more selections are made and the list grows smaller.
Constants
- SIGIL
Public Class Methods
new(symbol, registry)
click to toggle source
Construct a unique rule, given the symbol to lookup and the registry to look it up in.
@param [Symbol] symbol @param [Calyx::Registry] registry
# File lib/calyx/syntax/unique.rb, line 15 def initialize(symbol, registry) @symbol = symbol.slice(1, symbol.length-1).to_sym @registry = registry end
Public Instance Methods
evaluate(options)
click to toggle source
Evaluate the unique rule, using the registry to handle the expansion and keep track of previous selections.
@param [Calyx::Options] options @return [Array]
# File lib/calyx/syntax/unique.rb, line 25 def evaluate(options) [@symbol, @registry.unique_expansion(@symbol)] end