Class: ControlledParagraph

Inherits:
Paragraph show all
Defined in:
lib/almirah/doc_items/controlled_paragraph.rb

Instance Attribute Summary collapse

Attributes inherited from Paragraph

#text

Instance Method Summary collapse

Methods inherited from Paragraph

#getTextWithoutSpaces

Constructor Details

#initialize(text, id) ⇒ ControlledParagraph



9
10
11
12
13
14
# File 'lib/almirah/doc_items/controlled_paragraph.rb', line 9

def initialize(text, id)
    @text = text
    @id = id
    @up_link = nil
    @down_links = nil
end

Instance Attribute Details

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

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/almirah/doc_items/controlled_paragraph.rb', line 5

def id
  @id
end

Returns the value of attribute up_link.



6
7
8
# File 'lib/almirah/doc_items/controlled_paragraph.rb', line 6

def up_link
  @up_link
end

Instance Method Details

#to_htmlObject



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
# File 'lib/almirah/doc_items/controlled_paragraph.rb', line 16

def to_html
    s = ''
    unless @@htmlTableRenderInProgress                    
        s += "<table>\n\r"
        s += "\t<thead> <th>#</th> <th>Text</th> <th>UL</th> <th>DL</th> <th>COV</th> </thead>\n\r"
        @@htmlTableRenderInProgress = true
    end
    s += "\t<tr>\n\r"
    s += "\t\t<td> <a name=\"#{@id}\"></a>#{@id} </td>\n\r"
    s += "\t\t<td>#{@text}</td>\n\r"

    if @up_link
        if tmp = /^([a-zA-Z]+)[-]\d+/.match(@up_link)
            up_link_doc_name = tmp[1].downcase
        end
        s += "\t\t<td><a href=\"./../#{up_link_doc_name}/#{up_link_doc_name}.html\" class=\"external\">#{@up_link}</a></td>\n\r"
    else
        s += "\t\t<td></td>\n\r"
    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
        s += "\t\t<td><a href=\"./../#{down_link_doc_name}/#{down_link_doc_name}.html\" class=\"external\">#{@down_links.length}</a></td>\n\r"
    else
        s += "\t\t<td></td>\n\r"
    end

    #s += "\t\t<td></td>\n\r"    # UL

    #s += "\t\t<td></td>\n\r"    # DL

    s += "\t\t<td></td>\n\r"    # COV

    s += "\t</tr>\n\r"
    return s
end