Class: Minesweeprb::Theme
- Inherits:
-
Object
- Object
- Minesweeprb::Theme
- Defined in:
- lib/minesweeprb/theme.rb
Instance Attribute Summary collapse
-
#colors ⇒ Object
readonly
Returns the value of attribute colors.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#sprites ⇒ Object
readonly
Returns the value of attribute sprites.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, sprites:, colors:) ⇒ Theme
constructor
A new instance of Theme.
Constructor Details
#initialize(name:, sprites:, colors:) ⇒ Theme
Returns a new instance of Theme.
7 8 9 10 11 |
# File 'lib/minesweeprb/theme.rb', line 7 def initialize(name:, sprites:, colors:) @name = name @sprites = sprites.freeze @colors = colors.freeze end |
Instance Attribute Details
#colors ⇒ Object (readonly)
Returns the value of attribute colors.
5 6 7 |
# File 'lib/minesweeprb/theme.rb', line 5 def colors @colors end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/minesweeprb/theme.rb', line 5 def name @name end |
#sprites ⇒ Object (readonly)
Returns the value of attribute sprites.
5 6 7 |
# File 'lib/minesweeprb/theme.rb', line 5 def sprites @sprites end |
Class Method Details
.[](name) ⇒ Object
20 21 22 |
# File 'lib/minesweeprb/theme.rb', line 20 def [](name) @registry[name] || raise(ArgumentError, "Unknown theme: #{name}. Available: #{names.join(', ')}") end |
.default ⇒ Object
28 29 30 |
# File 'lib/minesweeprb/theme.rb', line 28 def default @registry['modern'] end |
.names ⇒ Object
24 25 26 |
# File 'lib/minesweeprb/theme.rb', line 24 def names @registry.keys end |
.register(theme) ⇒ Object
16 17 18 |
# File 'lib/minesweeprb/theme.rb', line 16 def register(theme) @registry[theme.name] = theme end |