Class: Elisp2any::Line
- Inherits:
-
Object
- Object
- Elisp2any::Line
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/elisp2any/line.rb
Class Method Summary collapse
-
.parse(string) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#initialize(chunks) ⇒ Line
constructor
:nodoc:.
Constructor Details
#initialize(chunks) ⇒ Line
:nodoc:
7 8 9 |
# File 'lib/elisp2any/line.rb', line 7 def initialize(chunks) # :nodoc: @chunks = chunks end |
Class Method Details
.parse(string) ⇒ Object
:nodoc:
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/elisp2any/line.rb', line 11 def self.parse(string) # :nodoc: scanner = StringScanner.new(string) chunks = [] until scanner.eos? if scanner.skip(/`(?<content>[^']+)'/) chunks << InlineCode.new(scanner[:content]) else chunk = scanner.getch if (last = chunks.last).is_a?(String) last << chunk else chunks << chunk end end end new(chunks) end |