Class: Bibtex::RuleSet
- Inherits:
-
Object
- Object
- Bibtex::RuleSet
- Defined in:
- lib/bibtex/lexer.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize ⇒ RuleSet
constructor
A new instance of RuleSet.
- #literals(words) ⇒ Object
- #match(regexp, result) ⇒ Object
Constructor Details
#initialize ⇒ RuleSet
Returns a new instance of RuleSet.
19 20 21 |
# File 'lib/bibtex/lexer.rb', line 19 def initialize @rules = [] end |
Instance Method Details
#each ⇒ Object
33 34 35 36 37 |
# File 'lib/bibtex/lexer.rb', line 33 def each @rules.each do |pair| yield pair[0], pair[1] end end |
#literals(words) ⇒ Object
27 28 29 30 31 |
# File 'lib/bibtex/lexer.rb', line 27 def literals(words) words.each do |w| match /#{w}/, w end end |
#match(regexp, result) ⇒ Object
23 24 25 |
# File 'lib/bibtex/lexer.rb', line 23 def match(regexp, result) @rules << [regexp, result] end |