Module: Coradoc::CoreModel::Builder::ElementBuilder Private
- Included in:
- Coradoc::CoreModel::Builder
- Defined in:
- lib/coradoc/core_model/builder/element_builder.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Element building module for Builder
Contains methods for building miscellaneous elements from AST structures.
Instance Method Summary collapse
-
#build_attribute(ast) ⇒ Object
private
Build single attribute.
-
#build_bibliography_entry(ast) ⇒ Object
private
Build bibliography entry.
-
#build_comment_block(ast) ⇒ Object
private
Build comment block.
-
#build_comment_line(ast) ⇒ Object
private
Build comment line.
-
#build_generic_element(ast) ⇒ Object
private
Build generic element for unknown types.
-
#build_header(ast) ⇒ Object
private
Build header element.
-
#build_include(ast) ⇒ Object
private
Build include directive.
-
#build_line_break(ast) ⇒ Object
private
Build line break element.
-
#build_section(ast) ⇒ Object
private
Build section element.
-
#build_section_contents(contents_ast) ⇒ Object
private
Build section contents.
-
#build_subsections(sections_ast) ⇒ Object
private
Build subsections.
-
#build_table(ast) ⇒ Object
private
Build table element.
-
#build_tag(ast) ⇒ Object
private
Build tag element.
-
#build_unparsed(ast) ⇒ Object
private
Build unparsed text element.
Instance Method Details
#build_attribute(ast) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build single attribute
157 158 159 160 161 162 163 |
# File 'lib/coradoc/core_model/builder/element_builder.rb', line 157 def build_attribute(ast) { key: ast[:key], value: ast[:value], line_break: ast[:line_break] } end |
#build_bibliography_entry(ast) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build bibliography entry
136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/coradoc/core_model/builder/element_builder.rb', line 136 def build_bibliography_entry(ast) bib_ast = ast[:bibliography_entry] || ast['bibliography_entry'] || ast { type: :bibliography_entry, anchor_name: bib_ast[:anchor_name] || bib_ast['anchor_name'], document_id: bib_ast[:document_id] || bib_ast['document_id'], ref_text: bib_ast[:ref_text] || bib_ast['ref_text'], line_break: bib_ast[:line_break] || bib_ast['line_break'] } end |
#build_comment_block(ast) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build comment block
74 75 76 77 78 79 80 81 |
# File 'lib/coradoc/core_model/builder/element_builder.rb', line 74 def build_comment_block(ast) comment_ast = ast[:comment_block] || ast['comment_block'] || ast { type: :comment_block, text: comment_ast[:comment_text] || comment_ast['comment_text'] } end |
#build_comment_line(ast) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build comment line
63 64 65 66 67 68 69 70 71 |
# File 'lib/coradoc/core_model/builder/element_builder.rb', line 63 def build_comment_line(ast) comment_ast = ast[:comment_line] || ast['comment_line'] || ast { type: :comment_line, text: comment_ast[:comment_text] || comment_ast['comment_text'], line_break: comment_ast[:line_break] || comment_ast['line_break'] } end |
#build_generic_element(ast) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build generic element for unknown types
149 150 151 152 153 154 |
# File 'lib/coradoc/core_model/builder/element_builder.rb', line 149 def build_generic_element(ast) { type: :unknown, ast: ast } end |
#build_header(ast) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build header element
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/coradoc/core_model/builder/element_builder.rb', line 13 def build_header(ast) header_ast = ast[:header] || ast { type: :header, title: header_ast[:title], author: header_ast[:author], revision: header_ast[:revision], id: header_ast[:id] } end |
#build_include(ast) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build include directive
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/coradoc/core_model/builder/element_builder.rb', line 84 def build_include(ast) include_ast = ast[:include] || ast['include'] || ast { type: :include, path: include_ast[:path] || include_ast['path'], attributes: build_attributes_private( include_ast[:attribute_list] || include_ast['attribute_list'] ), line_break: include_ast[:line_break] || include_ast['line_break'] } end |
#build_line_break(ast) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build line break element
55 56 57 58 59 60 |
# File 'lib/coradoc/core_model/builder/element_builder.rb', line 55 def build_line_break(ast) { type: :line_break, content: ast[:line_break] || ast['line_break'] } end |
#build_section(ast) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build section element
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/coradoc/core_model/builder/element_builder.rb', line 26 def build_section(ast) section_ast = ast[:section] || ast { type: :section, title: section_ast[:title], id: section_ast[:id], level: extract_level(section_ast), contents: build_section_contents(section_ast[:contents]), sections: build_subsections(section_ast[:sections]), attribute_list: section_ast[:attribute_list] } end |
#build_section_contents(contents_ast) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build section contents
41 42 43 44 45 |
# File 'lib/coradoc/core_model/builder/element_builder.rb', line 41 def build_section_contents(contents_ast) return [] unless contents_ast Array(contents_ast).map { |content| build_element(content) }.compact end |
#build_subsections(sections_ast) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build subsections
48 49 50 51 52 |
# File 'lib/coradoc/core_model/builder/element_builder.rb', line 48 def build_subsections(sections_ast) return [] unless sections_ast Array(sections_ast).map { |section| build_element(section) }.compact end |
#build_table(ast) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build table element
98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/coradoc/core_model/builder/element_builder.rb', line 98 def build_table(ast) table_ast = ast[:table] || ast['table'] || ast { type: :table, title: table_ast[:title] || table_ast['title'], id: table_ast[:id] || table_ast['id'], rows: table_ast[:rows] || table_ast['rows'] || [], attributes: build_attributes_private( table_ast[:attribute_list] || table_ast['attribute_list'] ) } end |
#build_tag(ast) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build tag element
121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/coradoc/core_model/builder/element_builder.rb', line 121 def build_tag(ast) tag_ast = ast[:tag] || ast['tag'] || ast { type: :tag, name: tag_ast[:name] || tag_ast['name'], attributes: build_attributes_private( tag_ast[:attribute_list] || tag_ast['attribute_list'] ), line_break: tag_ast[:line_break] || tag_ast['line_break'], prefix: tag_ast[:prefix] || tag_ast['prefix'] } end |
#build_unparsed(ast) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build unparsed text element
113 114 115 116 117 118 |
# File 'lib/coradoc/core_model/builder/element_builder.rb', line 113 def build_unparsed(ast) { type: :unparsed, text: (ast[:unparsed] || ast['unparsed']).to_s } end |