Class: CodeBlock
- Inherits:
-
DocItem
- Object
- TextLineBuilderContext
- TextLine
- DocItem
- CodeBlock
- Defined in:
- lib/almirah/doc_items/code_block.rb
Constant Summary
Constants included from HtmlSafe
Instance Attribute Summary collapse
-
#code_lines ⇒ Object
Returns the value of attribute code_lines.
-
#suggested_format ⇒ Object
Returns the value of attribute suggested_format.
Attributes inherited from DocItem
Instance Method Summary collapse
-
#initialize(suggested_format) ⇒ CodeBlock
constructor
A new instance of CodeBlock.
- #to_html ⇒ Object
Methods inherited from DocItem
#get_url, #owner_document, #split_table_cells
Methods inherited from TextLine
#bold, #bold_and_italic, broken_links, #format_string, #inline_code, #italic, #link, link_registry, link_registry=, #literal_text, #owner_document, record_broken_link, reset_broken_links, #wiki_link
Methods included from HtmlSafe
#escape_attr, #escape_text, #safe_url
Methods inherited from TextLineBuilderContext
#bold, #bold_and_italic, #inline_code, #italic, #link, #literal_text, #wiki_link
Constructor Details
#initialize(suggested_format) ⇒ CodeBlock
Returns a new instance of CodeBlock.
6 7 8 9 |
# File 'lib/almirah/doc_items/code_block.rb', line 6 def initialize(suggested_format) @suggested_format = suggested_format @code_lines = [] end |
Instance Attribute Details
#code_lines ⇒ Object
Returns the value of attribute code_lines.
4 5 6 |
# File 'lib/almirah/doc_items/code_block.rb', line 4 def code_lines @code_lines end |
#suggested_format ⇒ Object
Returns the value of attribute suggested_format.
4 5 6 |
# File 'lib/almirah/doc_items/code_block.rb', line 4 def suggested_format @suggested_format end |
Instance Method Details
#to_html ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/almirah/doc_items/code_block.rb', line 11 def to_html s = '' if @@html_table_render_in_progress s += "</table>\n" @@html_table_render_in_progress = false end s += '<code>' @code_lines.each do |l| s += escape_text(l) + ' </br>' # ADR-188/SRS-096: code content is inert text end s += "</code>\n" s end |