Sha256: 47635694ebff393e3e511b11bf23496ec9970765b0bf7220b7567f52815ad021

Contents?: true

Size: 728 Bytes

Versions: 5

Compression:

Stored size: 728 Bytes

Contents

# frozen_string_literal: true

module RubyJard
  ##
  # Abstract class of all color scheme.
  class ColorScheme
    def initialize(styles: self.class.const_get(:STYLES))
      @styles = {}
      styles.each do |element, element_styles|
        update(element, element_styles)
      end
    end

    ##
    # 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
    def styles_for(element)
      @styles[element].dup
    end

    def update(element, styles)
      @styles[element] = styles
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ruby_jard-0.3.1 lib/ruby_jard/color_scheme.rb
ruby_jard-0.3.0 lib/ruby_jard/color_scheme.rb
ruby_jard-0.2.3 lib/ruby_jard/color_scheme.rb
ruby_jard-0.2.2 lib/ruby_jard/color_scheme.rb
ruby_jard-0.2.1 lib/ruby_jard/color_scheme.rb