Class: RubyJard::ColorScheme
- Inherits:
-
Object
- Object
- RubyJard::ColorScheme
- Defined in:
- lib/ruby_jard/color_scheme.rb
Overview
Abstract class of all color scheme.
Direct Known Subclasses
RubyJard::ColorSchemes::DeepSpaceColorScheme, RubyJard::ColorSchemes::GruvboxColorScheme, RubyJard::ColorSchemes::OneHalfDarkColorScheme, RubyJard::ColorSchemes::OneHalfLightColorScheme, RubyJard::ColorSchemes::X256ColorScheme, RubyJard::ColorSchemes::X256LightColorScheme
Instance Method Summary collapse
-
#initialize(styles: self.class.const_get(:STYLES)) ⇒ ColorScheme
constructor
A new instance of ColorScheme.
-
#styles_for(element) ⇒ Object
Fetch the styles for a particular element defined in the scheme.
- #update(element, styles) ⇒ Object
Constructor Details
#initialize(styles: self.class.const_get(:STYLES)) ⇒ ColorScheme
Returns a new instance of ColorScheme.
7 8 9 10 11 12 |
# File 'lib/ruby_jard/color_scheme.rb', line 7 def initialize(styles: self.class.const_get(:STYLES)) @styles = {} styles.each do |element, element_styles| update(element, element_styles) end end |
Instance Method Details
#styles_for(element) ⇒ Object
Fetch the styles for a particular element defined in the scheme. This method returns an array of two or more elements:
-
First element is foreground color
-
Second element is background color
-
The rest is decorating items, such as underline, italic
20 21 22 |
# File 'lib/ruby_jard/color_scheme.rb', line 20 def styles_for(element) @styles[element].dup end |
#update(element, styles) ⇒ Object
24 25 26 |
# File 'lib/ruby_jard/color_scheme.rb', line 24 def update(element, styles) @styles[element] = styles end |