Class: DaimonMarkdown::Plugin::TableOfContents::Header
- Inherits:
-
Object
- Object
- DaimonMarkdown::Plugin::TableOfContents::Header
- Defined in:
- lib/daimon_markdown/plugin/toc.rb
Instance Attribute Summary collapse
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#unique_id ⇒ Object
Returns the value of attribute unique_id.
Instance Method Summary collapse
- #content? ⇒ Boolean
-
#initialize(node) ⇒ Header
constructor
A new instance of Header.
- #link ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(node) ⇒ Header
Returns a new instance of Header.
55 56 57 58 59 60 |
# File 'lib/daimon_markdown/plugin/toc.rb', line 55 def initialize(node) @node = node @level = node.name.tr("h", "").to_i @text = node.text @unique_id = "" end |
Instance Attribute Details
#level ⇒ Object (readonly)
Returns the value of attribute level.
53 54 55 |
# File 'lib/daimon_markdown/plugin/toc.rb', line 53 def level @level end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
53 54 55 |
# File 'lib/daimon_markdown/plugin/toc.rb', line 53 def text @text end |
#unique_id ⇒ Object
Returns the value of attribute unique_id.
53 54 55 |
# File 'lib/daimon_markdown/plugin/toc.rb', line 53 def unique_id @unique_id end |
Instance Method Details
#content? ⇒ Boolean
67 68 69 |
# File 'lib/daimon_markdown/plugin/toc.rb', line 67 def content? @node.children.first end |
#link ⇒ Object
71 72 73 |
# File 'lib/daimon_markdown/plugin/toc.rb', line 71 def link %Q(<a href="##{unique_id}">#{text}</a>) end |
#to_s ⇒ Object
75 76 77 |
# File 'lib/daimon_markdown/plugin/toc.rb', line 75 def to_s @node.to_s end |