Class: Elisp2any::Line
- Inherits:
-
Object
- Object
- Elisp2any::Line
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/elisp2any/line.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(chunks) ⇒ Line
constructor
:nodoc:.
Constructor Details
#initialize(chunks) ⇒ Line
:nodoc:
23 24 25 |
# File 'lib/elisp2any/line.rb', line 23 def initialize(chunks) # :nodoc: @chunks = chunks end |
Class Method Details
.parse(string) ⇒ Object
:nodoc:
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/elisp2any/line.rb', line 27 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 |
.scan(scanner) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/elisp2any/line.rb', line 9 def self.scan(scanner) pos = scanner.pos comment = Comment.scan(scanner) or return unless comment.colons == 2 scanner.pos = pos return end unless comment.padding[0] == " " raise Error, "line comment should have a whitespace padding" end content = "#{comment.padding[1..]}#{comment.content}" new(Text.scan(content).to_a) end |