Class: RubyJard::ColorScheme

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_jard/color_scheme.rb

Overview

Abstract class of all color scheme.

Instance Method Summary collapse

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