Class: GuideEmUp::Theme

Inherits:
Object
  • Object
show all
Defined in:
lib/guide-em-up/theme.rb

Defined Under Namespace

Classes: ThemeEntry

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir) ⇒ Theme

Returns a new instance of Theme.



5
6
7
8
9
# File 'lib/guide-em-up/theme.rb', line 5

def initialize(dir)
  @dir = dir
  @templates = Dir["#{@dir}/*.erb"].sort
  @template = @templates.first
end

Instance Attribute Details

#templateObject (readonly)

Returns the value of attribute template.



11
12
13
# File 'lib/guide-em-up/theme.rb', line 11

def template
  @template
end

Instance Method Details

#allObject



18
19
20
21
22
23
# File 'lib/guide-em-up/theme.rb', line 18

def all
  @templates.map do |tmpl|
    name = File.basename(tmpl, '.erb')
    ThemeEntry.new(name, tmpl == template)
  end
end

#current=(tmpl) ⇒ Object



13
14
15
16
# File 'lib/guide-em-up/theme.rb', line 13

def current=(tmpl)
  filename  = "#{@dir}/#{tmpl}.erb"
  @template = filename if File.exists?(filename)
end