Class: Przn::Theme
- Inherits:
-
Object
- Object
- Przn::Theme
- Defined in:
- lib/przn/theme.rb
Constant Summary collapse
- DEFAULT_PATH =
File.('../../../default_theme.yml', __FILE__)
Instance Attribute Summary collapse
-
#bg ⇒ Object
readonly
Returns the value of attribute bg.
-
#bullet ⇒ Object
readonly
Returns the value of attribute bullet.
-
#bullet_size ⇒ Object
readonly
Returns the value of attribute bullet_size.
-
#colors ⇒ Object
readonly
Returns the value of attribute colors.
-
#font ⇒ Object
readonly
Returns the value of attribute font.
-
#heading_face ⇒ Object
readonly
Returns the value of attribute heading_face.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(config) ⇒ Theme
constructor
A new instance of Theme.
Constructor Details
#initialize(config) ⇒ Theme
Returns a new instance of Theme.
44 45 46 47 48 49 50 51 |
# File 'lib/przn/theme.rb', line 44 def initialize(config) @colors = config[:colors] @font = config[:font] @bullet = config[:bullet] @bullet_size = config[:bullet_size] @bg = config[:bg] @heading_face = config[:heading_face] end |
Instance Attribute Details
#bg ⇒ Object (readonly)
Returns the value of attribute bg.
9 10 11 |
# File 'lib/przn/theme.rb', line 9 def bg @bg end |
#bullet ⇒ Object (readonly)
Returns the value of attribute bullet.
9 10 11 |
# File 'lib/przn/theme.rb', line 9 def bullet @bullet end |
#bullet_size ⇒ Object (readonly)
Returns the value of attribute bullet_size.
9 10 11 |
# File 'lib/przn/theme.rb', line 9 def bullet_size @bullet_size end |
#colors ⇒ Object (readonly)
Returns the value of attribute colors.
9 10 11 |
# File 'lib/przn/theme.rb', line 9 def colors @colors end |
#font ⇒ Object (readonly)
Returns the value of attribute font.
9 10 11 |
# File 'lib/przn/theme.rb', line 9 def font @font end |
#heading_face ⇒ Object (readonly)
Returns the value of attribute heading_face.
9 10 11 |
# File 'lib/przn/theme.rb', line 9 def heading_face @heading_face end |
Class Method Details
.default ⇒ Object
27 28 29 |
# File 'lib/przn/theme.rb', line 27 def self.default new(load_yaml(DEFAULT_PATH)) end |
.load(path) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/przn/theme.rb', line 11 def self.load(path) raise ArgumentError, "Theme file not found: #{path}" unless File.exist?(path) defaults = load_yaml(DEFAULT_PATH) overrides = load_yaml(path) merged = { colors: defaults[:colors].merge(overrides[:colors] || {}), font: defaults[:font].merge(overrides[:font] || {}), bullet: overrides[:bullet] || defaults[:bullet], bullet_size: overrides[:bullet_size] || defaults[:bullet_size], bg: defaults[:bg].merge(overrides[:bg] || {}), heading_face: overrides[:heading_face] || defaults[:heading_face], } new(merged) end |