Class: 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(text, id) ⇒ ControlledParagraph
constructor
A new instance of ControlledParagraph.
- #to_html ⇒ Object
Methods inherited from Paragraph
Methods inherited from TextLine
add_lazy_doc_id, #bold, #bold_and_italic, #change_state, #format_string, #italic, #link
Constructor Details
#initialize(text, id) ⇒ ControlledParagraph
Returns a new instance of ControlledParagraph.
10 11 12 13 14 15 16 |
# File 'lib/almirah/doc_items/controlled_paragraph.rb', line 10 def initialize(text, id) @text = text.strip @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.
8 9 10 |
# File 'lib/almirah/doc_items/controlled_paragraph.rb', line 8 def coverage_links @coverage_links end |
#down_links ⇒ Object
Returns the value of attribute down_links.
7 8 9 |
# File 'lib/almirah/doc_items/controlled_paragraph.rb', line 7 def down_links @down_links end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/almirah/doc_items/controlled_paragraph.rb', line 5 def id @id end |
#up_link_ids ⇒ Object
Returns the value of attribute up_link_ids.
6 7 8 |
# File 'lib/almirah/doc_items/controlled_paragraph.rb', line 6 def up_link_ids @up_link_ids end |
Instance Method Details
#to_html ⇒ Object
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 |
# File 'lib/almirah/doc_items/controlled_paragraph.rb', line 18 def to_html s = '' unless @@htmlTableRenderInProgress s += "<table class=\"controlled\">\n" s += "\t<thead> <th>#</th> <th></th> <th>UL</th> <th>DL</th> <th>COV</th> </thead>\n" @@htmlTableRenderInProgress = true end f_text = format_string(@text) s += "\t<tr>\n" s += "\t\t<td class=\"item_id\"> <a name=\"#{@id}\" id=\"#{@id}\" href=\"##{@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\">#{@up_link_ids[0]}</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\">#{@up_link_ids.length}</a>" s += "</div>" s += "<div id=\"DLS_#{@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\">#{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\">#{@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\">#{@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\">#{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 s += "\t\t<td class=\"item_id\"><a href=\"./../../tests/protocols/#{cov_link_doc_name}/#{cov_link_doc_name}.html\" class=\"external\">#{@coverage_links.length}</a></td>\n" else s += "\t\t<td class=\"item_id\"></td>\n" end s += "\t</tr>\n" return s end |