Class: MediaWikiHTMLGenerator::TocGenerator::TocNode

Inherits:
Object
  • Object
show all
Defined in:
lib/mediacloth/mediawikihtmlgenerator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTocNode

Returns a new instance of TocNode.



246
247
248
# File 'lib/mediacloth/mediawikihtmlgenerator.rb', line 246

def initialize
    @children = []
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



243
244
245
# File 'lib/mediacloth/mediawikihtmlgenerator.rb', line 243

def children
  @children
end

#parentObject

Returns the value of attribute parent.



244
245
246
# File 'lib/mediacloth/mediawikihtmlgenerator.rb', line 244

def parent
  @parent
end

#sectionObject

Returns the value of attribute section.



245
246
247
# File 'lib/mediacloth/mediawikihtmlgenerator.rb', line 245

def section
  @section
end

Instance Method Details

#add_child(child) ⇒ Object



250
251
252
253
# File 'lib/mediacloth/mediawikihtmlgenerator.rb', line 250

def add_child(child)
    @children << child
    child.parent = self
end

#levelObject



255
256
257
258
259
260
261
262
263
# File 'lib/mediacloth/mediawikihtmlgenerator.rb', line 255

def level
    res = 0
    node = self
    while p = node.parent
        res += 1
        node = p
    end
    res
end

#numberObject



265
266
267
268
269
270
271
272
273
# File 'lib/mediacloth/mediawikihtmlgenerator.rb', line 265

def number
    res = ''
    node = self
    while p = node.parent
        res = "#{p.children.index(node)+1}." + res
        node = p
    end
    res
end