Class: TocList
- Inherits:
-
Object
- Object
- TocList
- Defined in:
- lib/toc_list.rb,
lib/toc_list/version.rb,
lib/toc_list/hash_method.rb
Constant Summary collapse
- VERSION =
'0.1.1'
- HashMethod =
lambda do |item| item.gsub(/\s/, '_') end
Instance Method Summary collapse
-
#initialize(toc_hash, tmpl = {}) ⇒ TocList
constructor
A new instance of TocList.
- #render ⇒ Object
- #sections ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(toc_hash, tmpl = {}) ⇒ TocList
Returns a new instance of TocList.
7 8 9 10 11 12 13 14 15 |
# File 'lib/toc_list.rb', line 7 def initialize toc_hash, tmpl={} @toc = toc_hash @title_tmpl_path = optional tmpl, :title @sections_tmpl_path = optional tmpl, :sections @container_tmpl_path = optional tmpl, :container @hash_method = block_given? ? hash_method : HashMethod end |
Instance Method Details
#render ⇒ Object
25 26 27 28 29 30 |
# File 'lib/toc_list.rb', line 25 def render @sections_tmpl ||= parse_tmpl @sections_tmpl_path toc = @sections_tmpl.result binding toc = wrap toc if parent.nil? toc end |
#sections ⇒ Object
21 22 23 |
# File 'lib/toc_list.rb', line 21 def sections @toc.values[0] end |
#title ⇒ Object
17 18 19 |
# File 'lib/toc_list.rb', line 17 def title @toc.keys[0] end |