Class: Rote::Filters::TOC::Heading
- Inherits:
-
Object
- Object
- Rote::Filters::TOC::Heading
- Defined in:
- lib/rote/filters/toc.rb
Overview
An individual Heading in the links
array.
Instance Attribute Summary collapse
-
#attrs ⇒ Object
The information held by this link.
-
#tag ⇒ Object
The information held by this link.
-
#title ⇒ Object
The information held by this link.
Instance Method Summary collapse
- #anchor ⇒ Object
-
#initialize(tag, title, attrs = {}) ⇒ Heading
constructor
A new instance of Heading.
- #to_s ⇒ Object
Constructor Details
#initialize(tag, title, attrs = {}) ⇒ Heading
Returns a new instance of Heading.
29 30 31 32 33 |
# File 'lib/rote/filters/toc.rb', line 29 def initialize(tag, title, attrs = {}) @tag = tag @title = title @attrs = attrs end |
Instance Attribute Details
#attrs ⇒ Object
The information held by this link
36 37 38 |
# File 'lib/rote/filters/toc.rb', line 36 def attrs @attrs end |
#tag ⇒ Object
The information held by this link
36 37 38 |
# File 'lib/rote/filters/toc.rb', line 36 def tag @tag end |
#title ⇒ Object
The information held by this link
36 37 38 |
# File 'lib/rote/filters/toc.rb', line 36 def title @title end |
Instance Method Details
#anchor ⇒ Object
38 39 40 |
# File 'lib/rote/filters/toc.rb', line 38 def anchor title.downcase.gsub(/<[^>]+>/,'').gsub(/[^a-z]+/,'_') end |
#to_s ⇒ Object
42 43 44 |
# File 'lib/rote/filters/toc.rb', line 42 def to_s %Q[<a #{"#{(attrs.collect { |k,v| "#{k}='#{v}'" }).join(' ')} " unless attrs.empty?}href='##{anchor}'>#{title}</a>] end |