Class: Blogaze::Theme
- Inherits:
-
Object
- Object
- Blogaze::Theme
- Defined in:
- lib/blogaze/theme.rb
Overview
Theme class
Constant Summary collapse
- REGISTERED =
Registered themes
{}
Class Attribute Summary collapse
-
.current ⇒ Object
Returns the value of attribute current.
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#templates ⇒ Object
Returns the value of attribute templates.
Class Method Summary collapse
-
.[](name) ⇒ Object
Returns the theme matching the supplied name.
-
.add { ... } ⇒ Object
Adds a new theme.
-
.registered ⇒ Array
Returns the registered themes.
-
.use(name) ⇒ Object
Sets the supplied name as the current theme to be used.
Class Attribute Details
.current ⇒ Object
Returns the value of attribute current.
30 31 32 |
# File 'lib/blogaze/theme.rb', line 30 def current @current end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
14 15 16 |
# File 'lib/blogaze/theme.rb', line 14 def name @name end |
#templates ⇒ Object
Returns the value of attribute templates.
15 16 17 |
# File 'lib/blogaze/theme.rb', line 15 def templates @templates end |
Class Method Details
.[](name) ⇒ Object
Returns the theme matching the supplied name.
48 49 50 51 52 |
# File 'lib/blogaze/theme.rb', line 48 def [](name) name = name.to_sym raise("Invalid theme #{name}") unless REGISTERED.key?(name) return REGISTERED[name] end |
.add { ... } ⇒ Object
Adds a new theme
37 38 39 40 41 |
# File 'lib/blogaze/theme.rb', line 37 def add theme = self.new yield theme REGISTERED[theme.name] = theme end |
.registered ⇒ Array
Returns the registered themes.
71 72 73 |
# File 'lib/blogaze/theme.rb', line 71 def registered REGISTERED.to_a end |
.use(name) ⇒ Object
Sets the supplied name as the current theme to be used.
60 61 62 63 64 |
# File 'lib/blogaze/theme.rb', line 60 def use(name) name = name.to_sym raise("Unable to use theme #{name}: not registered") unless REGISTERED.key?(name) @current = REGISTERED[name] end |