Class: Rocco::Layout
- Inherits:
-
Mustache
- Object
- Mustache
- Rocco::Layout
- Defined in:
- lib/rocco/layout.rb
Instance Method Summary collapse
-
#initialize(doc, file = nil) ⇒ Layout
constructor
A new instance of Layout.
- #sections ⇒ Object
- #sources ⇒ Object
- #sources? ⇒ Boolean
- #title ⇒ Object
Constructor Details
#initialize(doc, file = nil) ⇒ Layout
Returns a new instance of Layout.
6 7 8 9 10 11 |
# File 'lib/rocco/layout.rb', line 6 def initialize(doc, file=nil) @doc = doc if not file.nil? Rocco::Layout.template_file = file end end |
Instance Method Details
#sections ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rocco/layout.rb', line 17 def sections num = 0 @doc.sections.map do |docs,code| { :docs => docs, :docs? => !docs.empty?, :header? => /^<h.>.+<\/h.>$/.match( docs ), :code => code, :code? => !code.empty?, :empty? => ( code.empty? && docs.empty? ), :num => (num += 1) } end end |
#sources ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/rocco/layout.rb', line 38 def sources @doc.sources.sort.map do |source| { :path => source, :basename => File.basename(source), :url => File.basename(source).split('.')[0..-2].join('.') + '.html' } end end |
#sources? ⇒ Boolean
34 35 36 |
# File 'lib/rocco/layout.rb', line 34 def sources? @doc.sources.length > 1 end |
#title ⇒ Object
13 14 15 |
# File 'lib/rocco/layout.rb', line 13 def title File.basename(@doc.file) end |