Module: Coradoc::AsciiDoc::Builder::BlockBuilder
- Included in:
- Coradoc::AsciiDoc::Builder
- Defined in:
- lib/coradoc/asciidoc/builder/block_builder.rb
Instance Method Summary collapse
- #build_annotation_block(ast) ⇒ Object
- #build_generic_block(ast) ⇒ Object
- #extract_block_content(ast) ⇒ Object
- #extract_block_lines(ast) ⇒ Object
Instance Method Details
#build_annotation_block(ast) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/coradoc/asciidoc/builder/block_builder.rb', line 7 def build_annotation_block(ast) Coradoc::CoreModel::AnnotationBlock.new( annotation_type: extract_annotation_type(ast), annotation_label: extract_annotation_label(ast), content: extract_block_content(ast), lines: extract_block_lines(ast), title: ast[:title], id: ast[:id], attributes: build_attributes_private(ast[:attribute_list]) ) end |
#build_generic_block(ast) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/coradoc/asciidoc/builder/block_builder.rb', line 19 def build_generic_block(ast) Coradoc::CoreModel::Block.new( delimiter_type: ast[:delimiter]&.to_s, content: extract_block_content(ast), lines: extract_block_lines(ast), title: ast[:title], id: ast[:id], attributes: build_attributes_private(ast[:attribute_list]) ) end |
#extract_block_content(ast) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/coradoc/asciidoc/builder/block_builder.rb', line 30 def extract_block_content(ast) return ast[:content] if ast[:content] if ast[:lines] lines = Array(ast[:lines]) return lines.map { |line| extract_text_content(line) }.join("\n") end '' end |
#extract_block_lines(ast) ⇒ Object
41 42 43 44 45 |
# File 'lib/coradoc/asciidoc/builder/block_builder.rb', line 41 def extract_block_lines(ast) return [] unless ast[:lines] Array(ast[:lines]).map { |line| extract_text_content(line) } end |