Class: Heading

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

Instance Attribute Summary collapse

Attributes inherited from Paragraph

#text

Attributes inherited from DocItem

#parent_doc

Instance Method Summary collapse

Methods inherited from Paragraph

#getTextWithoutSpaces

Methods inherited from TextLine

add_lazy_doc_id, #bold, #bold_and_italic, #change_state, #format_string, #italic, #link

Constructor Details

#initialize(text, level) ⇒ Heading

Returns a new instance of Heading.



8
9
10
11
12
# File 'lib/almirah/doc_items/heading.rb', line 8

def initialize(text, level)
    @text = text
    @level = level
    @anchor_id = getTextWithoutSpaces()
end

Instance Attribute Details

#anchor_idObject

Returns the value of attribute anchor_id.



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

def anchor_id
  @anchor_id
end

#levelObject

Returns the value of attribute level.



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

def level
  @level
end

Instance Method Details

#to_htmlObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/almirah/doc_items/heading.rb', line 14

def to_html
    s = ''
    if @@htmlTableRenderInProgress
        s += "</table>\n"
        @@htmlTableRenderInProgress = false
    end
    headingLevel = level.to_s 
    s += "<a name=\"#{@anchor_id}\"></a>\n"
    s += "<h#{headingLevel}> #{@text} <a href=\"\##{@anchor_id}\" class=\"heading_anchor\">"
    s += "&para;</a></h#{headingLevel}>"
    return s
end