Class: Elisp2any::Section
- Inherits:
-
Object
- Object
- Elisp2any::Section
- Extended by:
- Forwardable
- Defined in:
- lib/elisp2any/section.rb
Instance Attribute Summary collapse
-
#blocks ⇒ Object
(also: #paragraphs)
readonly
Returns the value of attribute blocks.
-
#heading ⇒ Object
readonly
Returns the value of attribute heading.
-
#sections ⇒ Object
readonly
Returns the value of attribute sections.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(heading:, blocks:, sections:) ⇒ Section
constructor
A new instance of Section.
Constructor Details
#initialize(heading:, blocks:, sections:) ⇒ Section
Returns a new instance of Section.
38 39 40 41 42 |
# File 'lib/elisp2any/section.rb', line 38 def initialize(heading:, blocks:, sections:) @heading = heading @blocks = blocks @sections = sections end |
Instance Attribute Details
#blocks ⇒ Object (readonly) Also known as: paragraphs
Returns the value of attribute blocks.
8 9 10 |
# File 'lib/elisp2any/section.rb', line 8 def blocks @blocks end |
#heading ⇒ Object (readonly)
Returns the value of attribute heading.
8 9 10 |
# File 'lib/elisp2any/section.rb', line 8 def heading @heading end |
#sections ⇒ Object (readonly)
Returns the value of attribute sections.
8 9 10 |
# File 'lib/elisp2any/section.rb', line 8 def sections @sections end |
Class Method Details
.scan(scanner) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/elisp2any/section.rb', line 13 def self.scan(scanner) heading = Heading.scan(scanner) or return heading.content = Text.scan(heading.content) Blanklines.scan(scanner) # optional blocks = [] while (blo = Paragraph.scan(scanner) || Codeblock.scan(scanner)) blocks << blo Blanklines.scan(scanner) # optional end pos = scanner.pos sections = [] while (section = scan(scanner)) if section.level == heading.level + 1 sections << section pos = scanner.pos elsif section.level >= heading.level + 2 raise Error, "too demoted heading" else scanner.pos = pos break end end new(heading:, blocks:, sections:) end |