Class: Rote::Filters::TOC::Heading

Inherits:
Object
  • Object
show all
Defined in:
lib/rote/filters/toc.rb

Overview

An individual Heading in the links array.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#attrsObject

The information held by this link



36
37
38
# File 'lib/rote/filters/toc.rb', line 36

def attrs
  @attrs
end

#tagObject

The information held by this link



36
37
38
# File 'lib/rote/filters/toc.rb', line 36

def tag
  @tag
end

#titleObject

The information held by this link



36
37
38
# File 'lib/rote/filters/toc.rb', line 36

def title
  @title
end

Instance Method Details

#anchorObject



38
39
40
# File 'lib/rote/filters/toc.rb', line 38

def anchor
  title.downcase.gsub(/<[^>]+>/,'').gsub(/[^a-z]+/,'_')
end

#to_sObject



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