Class: Natspec::Document
- Inherits:
-
Object
- Object
- Natspec::Document
- Defined in:
- lib/natspec.rb
Instance Attribute Summary collapse
-
#functions ⇒ Object
readonly
Returns the value of attribute functions.
-
#head ⇒ Object
readonly
Returns the value of attribute head.
-
#sections ⇒ Object
readonly
Returns the value of attribute sections.
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Instance Method Summary collapse
- #_parse_sections(sections) ⇒ Object
-
#initialize(head, sections) ⇒ Document
constructor
A new instance of Document.
Constructor Details
#initialize(head, sections) ⇒ Document
Returns a new instance of Document.
10 11 12 13 14 15 |
# File 'lib/natspec.rb', line 10 def initialize( head, sections ) @head = head @sections = sections @storage, @functions = _parse_sections( @sections ) end |
Instance Attribute Details
#functions ⇒ Object (readonly)
Returns the value of attribute functions.
8 9 10 |
# File 'lib/natspec.rb', line 8 def functions @functions end |
#head ⇒ Object (readonly)
Returns the value of attribute head.
8 9 10 |
# File 'lib/natspec.rb', line 8 def head @head end |
#sections ⇒ Object (readonly)
Returns the value of attribute sections.
8 9 10 |
# File 'lib/natspec.rb', line 8 def sections @sections end |
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
8 9 10 |
# File 'lib/natspec.rb', line 8 def storage @storage end |
Instance Method Details
#_parse_sections(sections) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/natspec.rb', line 17 def _parse_sections( sections ) storage = {} functions = {} sections.each do |heading, lines| if (m=heading.match(/\Astorage[ ]+(.+)[ ]+(?<id>[_A-Za-z0-9]+)\z/)) storage[ m[:id] ] = [heading,lines] elsif (m=heading.match(/\Afunction[ ]+(?<id>[_A-Za-z0-9]+)([ (]|\z)/)) functions[ m[:id] ] = [heading,lines] else puts "!! ERROR - unsupported heading type in line >#{heading}<; sorry" exit 1 end end [storage, functions] end |