Class: Rocco::Layout

Inherits:
Mustache
  • Object
show all
Defined in:
lib/rocco/layout.rb

Instance Method Summary collapse

Constructor Details

#initialize(doc) ⇒ Layout

Returns a new instance of Layout.



6
7
8
# File 'lib/rocco/layout.rb', line 6

def initialize(doc)
  @doc = doc
end

Instance Method Details

#sectionsObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/rocco/layout.rb', line 14

def sections
  num = 0
  @doc.sections.map do |docs,code|
    {
      :docs  => docs,
      :code  => code,
      :num   => (num += 1)
    }
  end
end

#sourcesObject



29
30
31
32
33
34
35
36
37
# File 'lib/rocco/layout.rb', line 29

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

Returns:

  • (Boolean)


25
26
27
# File 'lib/rocco/layout.rb', line 25

def sources?
  @doc.sources.length > 1
end

#titleObject



10
11
12
# File 'lib/rocco/layout.rb', line 10

def title
  File.basename(@doc.file)
end