Class: Blogaze::Theme

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

Overview

Theme class

Constant Summary collapse

REGISTERED =

Registered themes

{}

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.currentObject

Returns the value of attribute current.



30
31
32
# File 'lib/blogaze/theme.rb', line 30

def current
  @current
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#templatesObject

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.

Parameters:

  • name (String)

    Themes 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

Yields:

  • 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

.registeredArray

Returns the registered themes.

Returns:

  • (Array)


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.

Parameters:

  • name (String)

    Themes name



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