Class: MediaWikiHTMLGenerator::TocGenerator::TocNode
- Inherits:
-
Object
- Object
- MediaWikiHTMLGenerator::TocGenerator::TocNode
- Defined in:
- lib/mediacloth/mediawikihtmlgenerator.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#section ⇒ Object
Returns the value of attribute section.
Instance Method Summary collapse
- #add_child(child) ⇒ Object
-
#initialize ⇒ TocNode
constructor
A new instance of TocNode.
- #level ⇒ Object
- #number ⇒ Object
Constructor Details
#initialize ⇒ TocNode
Returns a new instance of TocNode.
246 247 248 |
# File 'lib/mediacloth/mediawikihtmlgenerator.rb', line 246 def initialize @children = [] end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
243 244 245 |
# File 'lib/mediacloth/mediawikihtmlgenerator.rb', line 243 def children @children end |
#parent ⇒ Object
Returns the value of attribute parent.
244 245 246 |
# File 'lib/mediacloth/mediawikihtmlgenerator.rb', line 244 def parent @parent end |
#section ⇒ Object
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 |
#level ⇒ Object
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 |
#number ⇒ Object
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 |