Module: Coradoc::Document

Defined in:
lib/coradoc/document.rb,
lib/coradoc/document/base.rb,
lib/coradoc/document/list.rb,
lib/coradoc/document/table.rb,
lib/coradoc/document/title.rb,
lib/coradoc/document/bibdata.rb,
lib/coradoc/document/attribute.rb,
lib/coradoc/document/paragraph.rb

Defined Under Namespace

Classes: Admonition, Attribute, Author, Base, Bibdata, Block, Glossaries, Header, Highlight, LineBreak, List, Paragraph, Revision, Section, Table, TextElement, Title

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.bibdataObject (readonly)

Returns the value of attribute bibdata.



18
19
20
# File 'lib/coradoc/document.rb', line 18

def bibdata
  @bibdata
end

.headerObject (readonly)

Returns the value of attribute header.



18
19
20
# File 'lib/coradoc/document.rb', line 18

def header
  @header
end

.sectionsObject (readonly)

Returns the value of attribute sections.



18
19
20
# File 'lib/coradoc/document.rb', line 18

def sections
  @sections
end

Class Method Details

.from_adoc(filename) ⇒ Object



20
21
22
23
# File 'lib/coradoc/document.rb', line 20

def from_adoc(filename)
  ast = Coradoc::Parser.parse(filename)
  Coradoc::Transformer.transform(ast)
end

.from_ast(elements) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/coradoc/document.rb', line 25

def from_ast(elements)
  @sections = []

  elements.each do |element|
    if element.is_a?(Coradoc::Document::Bibdata)
      @bibdata = element
    end

    if element.is_a?(Coradoc::Document::Header)
      @header = element
    end

    if element.is_a?(Coradoc::Document::Section)
      @sections << element
    end
  end

  self
end