Class: Rokko::IndexLayout
- Defined in:
- lib/rokko/index_layout.rb
Overview
Layout containing README file and “Table of Contents” with links to all generated HTML files
Instance Method Summary collapse
-
#dirs ⇒ Object
Groupped sources by dirname.
-
#initialize(sources, readme = '', options = {}) ⇒ IndexLayout
constructor
A new instance of IndexLayout.
- #readme ⇒ Object
- #readme? ⇒ Boolean
- #sources ⇒ Object
- #title ⇒ Object
Methods inherited from Layout
#highlight_js, #sections, #sources?, #styles
Constructor Details
#initialize(sources, readme = '', options = {}) ⇒ IndexLayout
Returns a new instance of IndexLayout.
6 7 8 9 10 |
# File 'lib/rokko/index_layout.rb', line 6 def initialize(sources, readme = '', = {}) @sources = sources @readme = readme @options = end |
Instance Method Details
#dirs ⇒ Object
Groupped sources by dirname
35 36 37 38 39 40 |
# File 'lib/rokko/index_layout.rb', line 35 def dirs sources.inject(Hash.new{ |hsh, key| hsh[key] = [] }) do |c, source| c[File.dirname(source[:path])].push(source) c end.sort.collect { |k, v| { dir: k, files: v } } end |
#readme ⇒ Object
16 17 18 |
# File 'lib/rokko/index_layout.rb', line 16 def readme Rokko::Rokko.renderer.render(@readme) end |
#readme? ⇒ Boolean
20 21 22 |
# File 'lib/rokko/index_layout.rb', line 20 def readme? @readme != "" end |
#sources ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/rokko/index_layout.rb', line 24 def sources @sources.sort.map do |source| { path: source, basename: File.basename(source), url: source.sub(Regexp.new("#{File.extname(source)}$"), ".html") } end end |
#title ⇒ Object
12 13 14 |
# File 'lib/rokko/index_layout.rb', line 12 def title "Table of Contents" end |