Class: Coradoc::Document::Section

Inherits:
Object
  • Object
show all
Defined in:
lib/coradoc/document/section.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = {})
  @title = title
  @id = options.fetch(:id, nil).to_s
  @contents = options.fetch(:contents, [])
  @sections = options.fetch(:sections, [])
end

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



3
4
5
# File 'lib/coradoc/document/section.rb', line 3

def contents
  @contents
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/coradoc/document/section.rb', line 3

def id
  @id
end

#sectionsObject (readonly)

Returns the value of attribute sections.



3
4
5
# File 'lib/coradoc/document/section.rb', line 3

def sections
  @sections
end

#titleObject (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

#contentObject



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

#glossariesObject



12
13
14
# File 'lib/coradoc/document/section.rb', line 12

def glossaries
  @glossaries ||= extract_glossaries
end