Class: Lm2doc::Theme

Inherits:
Object
  • Object
show all
Defined in:
lib/lm2doc/theme.rb,
lib/lm2doc/theme.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dirObject

Returns the value of attribute dir.



27
28
29
# File 'lib/lm2doc/theme.rb', line 27

def dir
  @dir
end

Class Method Details

.instance(name) ⇒ Object



19
20
21
22
# File 'lib/lm2doc/theme.rb', line 19

def instance(name)
  @pool ||= {}
  @pool[name]
end

.register(name, theme) ⇒ Object



14
15
16
17
# File 'lib/lm2doc/theme.rb', line 14

def register(name, theme)
  @pool ||= {}
  @pool[name] = theme
end

Instance Method Details

#assetsObject



33
34
35
36
37
# File 'lib/lm2doc/theme.rb', line 33

def assets
  [
    Resource::Compass.new(self.dir)
  ]
end

#render(hash) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/lm2doc/theme.rb', line 39

def render(hash)
  erb_file = theme_file_pathname("template.html.erb")
  template = ERB.new(erb_file.read)
  
  @body = hash[:article]
  @title = hash[:title]
  template.result(binding)
end

#theme_file_pathname(file) ⇒ Object



29
30
31
# File 'lib/lm2doc/theme.rb', line 29

def theme_file_pathname(file)
  self.dir.join(file)
end

#write_assets(dir) ⇒ Object



48
49
50
51
52
# File 'lib/lm2doc/theme.rb', line 48

def write_assets(dir)
  self.assets.each do |asset|
    asset.write(dir)
  end
end