Class: RubyJard::ColorSchemes

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/ruby_jard/color_schemes.rb,
lib/ruby_jard/color_schemes/256_color_scheme.rb,
lib/ruby_jard/color_schemes/gruvbox_color_scheme.rb,
lib/ruby_jard/color_schemes/256_light_color_scheme.rb,
lib/ruby_jard/color_schemes/deep_space_color_scheme.rb,
lib/ruby_jard/color_schemes/one_half_dark_color_scheme.rb,
lib/ruby_jard/color_schemes/one_half_light_color_scheme.rb

Overview

Color scheme registry.

Defined Under Namespace

Classes: DeepSpaceColorScheme, GruvboxColorScheme, OneHalfDarkColorScheme, OneHalfLightColorScheme, X256ColorScheme, X256LightColorScheme

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeColorSchemes

Returns a new instance of ColorSchemes.



18
19
20
# File 'lib/ruby_jard/color_schemes.rb', line 18

def initialize
  @color_scheme_registry = {}
end

Class Method Details

.instanceObject



13
14
15
# File 'lib/ruby_jard/color_schemes.rb', line 13

def instance
  @instance ||= new
end

Instance Method Details

#[](name) ⇒ Object Also known as: get



30
31
32
# File 'lib/ruby_jard/color_schemes.rb', line 30

def [](name)
  @color_scheme_registry[name.to_s.strip]
end

#add_color_scheme(name, color_scheme_class) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/ruby_jard/color_schemes.rb', line 22

def add_color_scheme(name, color_scheme_class)
  unless color_scheme_class < RubyJard::ColorScheme
    raise RubyJard::Error, "#{color_scheme_class} must implement, and inherit from #{RubyJard::ColorScheme}"
  end

  @color_scheme_registry[name] = color_scheme_class
end

#each(&block) ⇒ Object



43
44
45
# File 'lib/ruby_jard/color_schemes.rb', line 43

def each(&block)
  @color_scheme_registry.each(&block)
end

#lengthObject



39
40
41
# File 'lib/ruby_jard/color_schemes.rb', line 39

def length
  @color_scheme_registry.length
end

#namesObject



35
36
37
# File 'lib/ruby_jard/color_schemes.rb', line 35

def names
  @color_scheme_registry.keys.sort.dup
end