Method: TemplateExpander#expand
- Defined in:
- lib/HDLRuby/template_expander.rb
#expand(str, res = "") ⇒ Object
Apply the expander to +str+ and put the result in +res+.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/HDLRuby/template_expander.rb', line 41 def (str,res = "") # Ensure the default rule is properly set up. self.finalize # Scan the string with each rule. scanner = StringScanner.new(str) until scanner.eos? do @rules.find do |rule| scanned = scanner.scan(rule.match) if scanned then res << rule.action.call(scanned) else false end end res << scanner.scan_until(@skip) end return res end |