Class: Calyx::Grammar::Production::Choices
- Inherits:
-
Object
- Object
- Calyx::Grammar::Production::Choices
- Defined in:
- lib/calyx.rb
Class Method Summary collapse
Instance Method Summary collapse
- #evaluate(registry) ⇒ Object
-
#initialize(collection) ⇒ Choices
constructor
A new instance of Choices.
Constructor Details
#initialize(collection) ⇒ Choices
Returns a new instance of Choices.
127 128 129 |
# File 'lib/calyx.rb', line 127 def initialize(collection) @collection = collection end |
Class Method Details
.parse(productions) ⇒ Object
116 117 118 119 120 121 122 123 124 125 |
# File 'lib/calyx.rb', line 116 def self.parse(productions) choices = productions.map do |choice| if choice.is_a?(String) Concat.parse(choice) elsif choice.is_a?(Symbol) NonTerminal.new(choice) end end self.new(choices) end |
Instance Method Details
#evaluate(registry) ⇒ Object
131 132 133 |
# File 'lib/calyx.rb', line 131 def evaluate(registry) @collection.sample.evaluate(registry) end |