Class: Elisp2any::Code

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/elisp2any/code.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(blocks) ⇒ Code

Returns a new instance of Code.



35
36
37
# File 'lib/elisp2any/code.rb', line 35

def initialize(blocks)
  @blocks = blocks
end

Class Method Details

.scan(scanner) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/elisp2any/code.rb', line 8

def self.scan(scanner)
  pos = scanner.pos
  heading = Elisp2any.scan_top_heading(scanner) or return
  unless heading == "Code:"
    scanner.pos = pos
    return
  end
  Blanklines.scan(scanner) # optional
  paragraphs = []
  while (par = Paragraph.scan(scanner))
    paragraphs << par
    Blanklines.scan(scanner) # optional
  end
  blocks = [paragraphs]
  pos = scanner.pos
  while (section = Section.scan(scanner))
    if section.heading.level == 1
      blocks << section
      pos = scanner.pos
    else
      scanner.pos = pos
      break
    end
  end
  new(blocks)
end

Instance Method Details

#sectionsObject



39
40
41
# File 'lib/elisp2any/code.rb', line 39

def sections
  @blocks.drop(1)
end