Class: Fabulator::Grammar::Expr::Rules
- Inherits:
-
Object
- Object
- Fabulator::Grammar::Expr::Rules
- Defined in:
- lib/fabulator/grammar/expr/rules.rb
Instance Method Summary collapse
- #add_alternative(a) ⇒ Object
-
#initialize ⇒ Rules
constructor
A new instance of Rules.
- #to_regex ⇒ Object
Constructor Details
#initialize ⇒ Rules
Returns a new instance of Rules.
3 4 5 |
# File 'lib/fabulator/grammar/expr/rules.rb', line 3 def initialize @alternatives = [ ] end |
Instance Method Details
#add_alternative(a) ⇒ Object
7 8 9 |
# File 'lib/fabulator/grammar/expr/rules.rb', line 7 def add_alternative(a) @alternatives << a end |
#to_regex ⇒ Object
11 12 13 |
# File 'lib/fabulator/grammar/expr/rules.rb', line 11 def to_regex Regexp.union(@alternatives.collect{|a| a.to_regex }) end |