Class: Elisp2any::Heading
- Inherits:
-
Object
- Object
- Elisp2any::Heading
- Extended by:
- Forwardable
- Defined in:
- lib/elisp2any/heading.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
Instance Method Summary collapse
-
#code? ⇒ Boolean
:nodoc:.
-
#commentary? ⇒ Boolean
:nodoc:.
-
#final_name ⇒ Object
:nodoc:.
-
#initialize(node, level, content) ⇒ Heading
constructor
:nodoc:.
-
#name_and_synopsis ⇒ Object
Returns nil if failed.
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
#content ⇒ Object (readonly)
Returns the value of attribute content.
6 7 8 |
# File 'lib/elisp2any/heading.rb', line 6 def content @content end |
#level ⇒ Object (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:
29 30 31 |
# File 'lib/elisp2any/heading.rb', line 29 def code? # :nodoc: @level == 1 && @content == 'Code:' end |
#commentary? ⇒ Boolean
:nodoc:
25 26 27 |
# File 'lib/elisp2any/heading.rb', line 25 def commentary? # :nodoc: @level == 1 && @content == 'Commentary:' end |
#final_name ⇒ Object
: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_synopsis ⇒ Object
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 |