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
Instance Method Details
#sections ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rocco/layout.rb', line 18 def sections num = 0 @doc.sections.map do |docs,code| is_header = /^<h.>(.+)<\/h.>$/.match( docs ) header_text = is_header && is_header[1].split.join("_") num += 1 { :docs => docs, :docs? => !docs.empty?, :header? => is_header, :code => code, :code? => !code.empty?, :empty? => ( code.empty? && docs.empty? ), :section_id => is_header ? header_text : num } end end |
#sources ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rocco/layout.rb', line 42 def sources currentpath = Pathname.new( File.dirname( @doc.file ) ) @doc.sources.sort.map do |source| htmlpath = Pathname.new( source.sub( Regexp.new( "#{File.extname(source)}$"), ".html" ) ) { :path => source, :basename => File.basename(source), :url => htmlpath.relative_path_from( currentpath ) } end end |
#sources? ⇒ Boolean
38 39 40 |
# File 'lib/rocco/layout.rb', line 38 def sources? @doc.sources.length > 1 end |
#title ⇒ Object
14 15 16 |
# File 'lib/rocco/layout.rb', line 14 def title File.basename(@doc.file) end |