Class: GuideEmUp::Theme
- Inherits:
-
Object
- Object
- GuideEmUp::Theme
- Defined in:
- lib/guide-em-up/theme.rb
Defined Under Namespace
Classes: ThemeEntry
Instance Attribute Summary collapse
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #all ⇒ Object
- #current=(tmpl) ⇒ Object
-
#initialize(dir) ⇒ Theme
constructor
A new instance of Theme.
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
#template ⇒ Object (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
#all ⇒ Object
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 |