Class: Banzai::Filter::TableOfContentsTagFilter::HeaderNode
- Inherits:
-
Object
- Object
- Banzai::Filter::TableOfContentsTagFilter::HeaderNode
- Defined in:
- lib/banzai/filter/table_of_contents_tag_filter.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
-
#initialize(node: nil, href: nil, previous_header: nil) ⇒ HeaderNode
constructor
A new instance of HeaderNode.
- #level ⇒ Object
- #text ⇒ Object
Constructor Details
#initialize(node: nil, href: nil, previous_header: nil) ⇒ HeaderNode
Returns a new instance of HeaderNode.
98 99 100 101 102 103 104 105 |
# File 'lib/banzai/filter/table_of_contents_tag_filter.rb', line 98 def initialize(node: nil, href: nil, previous_header: nil) @node = node @href = CGI.escape(href) if href @children = [] @parent = find_parent(previous_header) @parent.children.push(self) if @parent end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
96 97 98 |
# File 'lib/banzai/filter/table_of_contents_tag_filter.rb', line 96 def children @children end |
#href ⇒ Object (readonly)
Returns the value of attribute href.
96 97 98 |
# File 'lib/banzai/filter/table_of_contents_tag_filter.rb', line 96 def href @href end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
96 97 98 |
# File 'lib/banzai/filter/table_of_contents_tag_filter.rb', line 96 def node @node end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
96 97 98 |
# File 'lib/banzai/filter/table_of_contents_tag_filter.rb', line 96 def parent @parent end |
Instance Method Details
#level ⇒ Object
107 108 109 110 111 |
# File 'lib/banzai/filter/table_of_contents_tag_filter.rb', line 107 def level return 0 unless node @level ||= node.name[1].to_i end |
#text ⇒ Object
113 114 115 116 117 |
# File 'lib/banzai/filter/table_of_contents_tag_filter.rb', line 113 def text return '' unless node @text ||= CGI.escapeHTML(node.text) end |