Class: Coradoc::Document::Section
- Inherits:
-
Object
- Object
- Coradoc::Document::Section
- Defined in:
- lib/coradoc/document/section.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
readonly
Returns the value of attribute contents.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#sections ⇒ Object
readonly
Returns the value of attribute sections.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #content ⇒ Object
- #glossaries ⇒ Object
-
#initialize(title, options = {}) ⇒ Section
constructor
A new instance of Section.
Constructor Details
#initialize(title, options = {}) ⇒ Section
Returns a new instance of Section.
5 6 7 8 9 10 |
# File 'lib/coradoc/document/section.rb', line 5 def initialize(title, = {}) @title = title @id = .fetch(:id, nil).to_s @contents = .fetch(:contents, []) @sections = .fetch(:sections, []) end |
Instance Attribute Details
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
3 4 5 |
# File 'lib/coradoc/document/section.rb', line 3 def contents @contents end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/coradoc/document/section.rb', line 3 def id @id end |
#sections ⇒ Object (readonly)
Returns the value of attribute sections.
3 4 5 |
# File 'lib/coradoc/document/section.rb', line 3 def sections @sections end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
3 4 5 |
# File 'lib/coradoc/document/section.rb', line 3 def title @title end |
Instance Method Details
#content ⇒ Object
16 17 18 19 20 |
# File 'lib/coradoc/document/section.rb', line 16 def content if contents.count == 1 && contents.first.is_a?(Coradoc::Document::Paragraph) contents.first end end |
#glossaries ⇒ Object
12 13 14 |
# File 'lib/coradoc/document/section.rb', line 12 def glossaries @glossaries ||= extract_glossaries end |