Class: Madness::TableOfContents
- Inherits:
-
Object
- Object
- Madness::TableOfContents
- Includes:
- ServerHelper
- Defined in:
- lib/madness/table_of_contents.rb
Overview
Generate a markdown Table of Contents for the entire site
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
Instance Method Summary collapse
- #build(file) ⇒ Object
-
#initialize(dir = nil) ⇒ TableOfContents
constructor
A new instance of TableOfContents.
- #toc ⇒ Object
Methods included from ServerHelper
#config, #disallowed_static?, #docroot, #find_static_file, #log, #theme
Constructor Details
#initialize(dir = nil) ⇒ TableOfContents
Returns a new instance of TableOfContents.
8 9 10 |
# File 'lib/madness/table_of_contents.rb', line 8 def initialize(dir = nil) @dir = dir || docroot end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
6 7 8 |
# File 'lib/madness/table_of_contents.rb', line 6 def dir @dir end |
Instance Method Details
#build(file) ⇒ Object
12 13 14 15 |
# File 'lib/madness/table_of_contents.rb', line 12 def build(file) file += '.md' unless file.end_with? '.md' File.write "#{dir}/#{file}", toc end |
#toc ⇒ Object
17 18 19 |
# File 'lib/madness/table_of_contents.rb', line 17 def toc @toc ||= toc!.join("\n") end |