Class: DocSection

Inherits:
Object
  • Object
show all
Defined in:
lib/almirah/dom/doc_section.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(heading) ⇒ DocSection

Returns a new instance of DocSection.



4
5
6
7
8
# File 'lib/almirah/dom/doc_section.rb', line 4

def initialize(heading)
  @sections = []
  @heading = heading
  @parent_section = nil
end

Instance Attribute Details

#headingObject

Returns the value of attribute heading.



2
3
4
# File 'lib/almirah/dom/doc_section.rb', line 2

def heading
  @heading
end

#parent_sectionObject

Returns the value of attribute parent_section.



2
3
4
# File 'lib/almirah/dom/doc_section.rb', line 2

def parent_section
  @parent_section
end

#sectionsObject

Returns the value of attribute sections.



2
3
4
# File 'lib/almirah/dom/doc_section.rb', line 2

def sections
  @sections
end

Instance Method Details

#to_htmlObject

rubocop:disable Metrics/MethodLength



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/almirah/dom/doc_section.rb', line 10

def to_html # rubocop:disable Metrics/MethodLength
  s = ''
  s += "\t<li onclick=\"nav_toggle_expand_list(this, event)\">" \
    '<span class="fa-li"><i class="fa fa-minus-square-o"> </i></span>'
  s += "<a href=\"##{@heading.anchor_id}\">#{@heading.}</a>\n"
  unless @sections.empty?
    s += "\t\t<ul class=\"fa-ul\">\n"
    @sections.each do |sub_section|
      s += sub_section.to_html
    end
    s += "\t\t</ul>\n"
  end
  s += "</li>\n"
  s
end