Class: DaimonMarkdown::Plugin::TableOfContents::Header

Inherits:
Object
  • Object
show all
Defined in:
lib/daimon_markdown/plugin/toc.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#levelObject (readonly)

Returns the value of attribute level.



53
54
55
# File 'lib/daimon_markdown/plugin/toc.rb', line 53

def level
  @level
end

#textObject (readonly)

Returns the value of attribute text.



53
54
55
# File 'lib/daimon_markdown/plugin/toc.rb', line 53

def text
  @text
end

#unique_idObject

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

Returns:

  • (Boolean)


67
68
69
# File 'lib/daimon_markdown/plugin/toc.rb', line 67

def content?
  @node.children.first
end


71
72
73
# File 'lib/daimon_markdown/plugin/toc.rb', line 71

def link
  %Q(<a href="##{unique_id}">#{text}</a>)
end

#to_sObject



75
76
77
# File 'lib/daimon_markdown/plugin/toc.rb', line 75

def to_s
  @node.to_s
end