Class: Elisp2any::Heading

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node, level, content) ⇒ Heading

:nodoc:



8
9
10
11
12
# File 'lib/elisp2any/heading.rb', line 8

def initialize(node, level, content) # :nodoc:
  @node = node
  @level = level
  @content = content
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



6
7
8
# File 'lib/elisp2any/heading.rb', line 6

def content
  @content
end

#levelObject (readonly)

Returns the value of attribute level.



6
7
8
# File 'lib/elisp2any/heading.rb', line 6

def level
  @level
end

Instance Method Details

#code?Boolean

:nodoc:

Returns:

  • (Boolean)


29
30
31
# File 'lib/elisp2any/heading.rb', line 29

def code? # :nodoc:
  @level == 1 && @content == 'Code:'
end

#commentary?Boolean

:nodoc:

Returns:

  • (Boolean)


25
26
27
# File 'lib/elisp2any/heading.rb', line 25

def commentary? # :nodoc:
  @level == 1 && @content == 'Commentary:'
end

#final_nameObject

:nodoc:



33
34
35
# File 'lib/elisp2any/heading.rb', line 33

def final_name # :nodoc:
  @content.match(/\A(?<name>.+?)\.el ends here\Z/)[:name]
end

#name_and_synopsisObject

Returns nil if failed



15
16
17
18
19
20
21
22
23
# File 'lib/elisp2any/heading.rb', line 15

def name_and_synopsis # :nodoc:
  scanner = StringScanner.new(@content)
  name = scanner.scan_until(/\.el/) or return
  name = name[nil...-3] or return
  scanner.skip(/\s+---\s+/) or return
  scanner.skip(/(?<synopsis>.+?)(:?\s+-\*- .+? -\*-)?\Z/) or return
  synopsis = scanner[:synopsis]
  return name, synopsis
end