Class: Elisp2any::Text
- Inherits:
-
Object
- Object
- Elisp2any::Text
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/elisp2any/text.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(tokens) ⇒ Text
constructor
A new instance of Text.
Constructor Details
#initialize(tokens) ⇒ Text
Returns a new instance of Text.
24 25 26 |
# File 'lib/elisp2any/text.rb', line 24 def initialize(tokens) @tokens = tokens end |
Class Method Details
.scan(scanner) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/elisp2any/text.rb', line 5 def self.scan(scanner) scanner = StringScanner.new(scanner) unless scanner.respond_to?(:skip) tokens = [] until scanner.eos? if scanner.skip(/`(?<content>[^']+)'/) tokens << { code: scanner[:content] } else char = scanner.getch case tokens in [*, String => last] last << char else tokens << char end end end new(tokens) end |