Class: ControlledParagraph
- Inherits:
-
Paragraph
- Object
- TextLineBuilderContext
- TextLine
- DocItem
- Paragraph
- ControlledParagraph
- Defined in:
- lib/almirah/doc_items/controlled_paragraph.rb
Instance Attribute Summary collapse
-
#coverage_links ⇒ Object
Returns the value of attribute coverage_links.
-
#down_links ⇒ Object
Returns the value of attribute down_links.
-
#id ⇒ Object
Returns the value of attribute id.
-
#up_link_ids ⇒ Object
Returns the value of attribute up_link_ids.
Attributes inherited from Paragraph
Attributes inherited from DocItem
Instance Method Summary collapse
-
#initialize(doc, text, id) ⇒ ControlledParagraph
constructor
A new instance of ControlledParagraph.
- #to_html ⇒ Object
Methods inherited from Paragraph
Methods inherited from DocItem
Methods inherited from TextLine
add_lazy_doc_id, #bold, #bold_and_italic, #format_string, #italic, #link
Methods inherited from TextLineBuilderContext
#bold, #bold_and_italic, #italic, #link
Constructor Details
#initialize(doc, text, id) ⇒ ControlledParagraph
Returns a new instance of ControlledParagraph.
6 7 8 9 10 11 12 13 |
# File 'lib/almirah/doc_items/controlled_paragraph.rb', line 6 def initialize(doc, text, id) super(doc, text) @parent_heading = doc.headings[-1] @id = id @up_link_ids = nil @down_links = nil @coverage_links = nil end |
Instance Attribute Details
#coverage_links ⇒ Object
Returns the value of attribute coverage_links.
4 5 6 |
# File 'lib/almirah/doc_items/controlled_paragraph.rb', line 4 def coverage_links @coverage_links end |
#down_links ⇒ Object
Returns the value of attribute down_links.
4 5 6 |
# File 'lib/almirah/doc_items/controlled_paragraph.rb', line 4 def down_links @down_links end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/almirah/doc_items/controlled_paragraph.rb', line 4 def id @id end |
#up_link_ids ⇒ Object
Returns the value of attribute up_link_ids.
4 5 6 |
# File 'lib/almirah/doc_items/controlled_paragraph.rb', line 4 def up_link_ids @up_link_ids end |
Instance Method Details
#to_html ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/almirah/doc_items/controlled_paragraph.rb', line 15 def to_html s = '' unless @@html_table_render_in_progress s += "<table class=\"controlled\">\n" s += "\t<thead> <th>#</th> <th></th> <th title=\"Up-links\">UL</th> <th title=\"Down-links\">DL</th> \ <th title=\"Test Coverage\">COV</th> </thead>\n" @@html_table_render_in_progress = true # rubocop:disable Style/ClassVars end f_text = format_string(@text) s += "\t<tr>\n" s += "\t\t<td class=\"item_id\"> \ <a name=\"#{@id}\" id=\"#{@id}\" href=\"##{@id}\" title=\"Paragraph ID\">#{@id}</a></td>\n" s += "\t\t<td class=\"item_text\">#{f_text}</td>\n" if @up_link_ids if @up_link_ids.length == 1 if tmp = /^([a-zA-Z]+)-\d+/.match(@up_link_ids[0]) up_link_doc_name = tmp[1].downcase end s += "\t\t<td class=\"item_id\">\ <a href=\"./../#{up_link_doc_name}/#{up_link_doc_name}.html##{@up_link_ids[0]}\" \ class=\"external\" title=\"Linked to\">#{@up_link_ids[0]}</a></td>\n" else s += "\t\t<td class=\"item_id\">" s += "<div id=\"UL_#{@id}\" style=\"display: block;\">" s += "<a href=\"#\" onclick=\"upLink_OnClick(this.parentElement); return false;\" \ class=\"external\" title=\"Number of up-links\">#{@up_link_ids.length}</a>" s += '</div>' s += "<div id=\"ULS_#{@id}\" style=\"display: none;\">" @up_link_ids.each do |lnk| if tmp = /^([a-zA-Z]+)-\d+/.match(lnk) up_link_doc_name = tmp[1].downcase end s += "\t\t\t<a href=\"./../#{up_link_doc_name}/#{up_link_doc_name}.html##{lnk}\" \ class=\"external\" title=\"Linked to\">#{lnk}</a>\n<br>" end s += '</div>' s += "</td>\n" end else s += "\t\t<td class=\"item_id\"></td>\n" end if @down_links if tmp = /^([a-zA-Z]+)-\d+/.match(@down_links[0].id) # guessing that all the links refer to one document down_link_doc_name = tmp[1].downcase end if @down_links.length == 1 s += "\t\t<td class=\"item_id\">\ <a href=\"./../#{down_link_doc_name}/#{down_link_doc_name}.html##{@down_links[0].id}\" \ class=\"external\" title=\"Referenced in\">#{@down_links[0].id}</a></td>\n" else s += "\t\t<td class=\"item_id\">" s += "<div id=\"DL_#{@id}\" style=\"display: block;\">" s += "<a href=\"#\" onclick=\"downlink_OnClick(this.parentElement); return false;\" \ class=\"external\" title=\"Number of references\">#{@down_links.length}</a>" s += '</div>' s += "<div id=\"DLS_#{@id}\" style=\"display: none;\">" @down_links.each do |lnk| s += "\t\t\t<a href=\"./../#{lnk.parent_doc.id}/#{lnk.parent_doc.id}.html##{lnk.id}\" \ class=\"external\" title=\"Referenced in\">#{lnk.id}</a>\n<br>" end s += '</div>' s += "</td>\n" end else s += "\t\t<td class=\"item_id\"></td>\n" end if @coverage_links if tmp = /^(.+)[.]\d+/.match(@coverage_links[0].id) # guessing that all the links refer to one document cov_link_doc_name = tmp[1].downcase end if @coverage_links.length == 1 s += "\t\t<td class=\"item_id\">\ <a href=\"./../../tests/protocols/#{cov_link_doc_name}/#{cov_link_doc_name}.html\" \ class=\"external\" title=\"Number of verification steps\">#{@coverage_links[0].id}</a></td>\n" else s += "\t\t<td class=\"item_id\">" s += "<div id=\"COV_#{@id}\" style=\"display: block;\">" s += "<a href=\"#\" onclick=\"coverageLink_OnClick(this.parentElement); return false;\" \ class=\"external\" title=\"Number of verification steps\">#{@coverage_links.length}</a>" s += '</div>' s += "<div id=\"COVS_#{@id}\" style=\"display: none;\">" @coverage_links.each do |lnk| s += "\t\t\t<a href=\"./../../tests/protocols/#{lnk.parent_doc.id}/#{lnk.parent_doc.id}.html##{lnk.id}\" \ class=\"external\" title=\"Covered in\">#{lnk.id}</a>\n<br>" end s += '</div>' s += "</td>\n" end else s += "\t\t<td class=\"item_id\"></td>\n" end s += "\t</tr>\n" s end |