Sha256: 9fbde957d223fff1e420ad123c0dba5ac13701c985177f4b5e86ac09c40cc72b

Contents?: true

Size: 691 Bytes

Versions: 1

Compression:

Stored size: 691 Bytes

Contents

# frozen_string_literal: true

module RubyJard
  ##
  # Color scheme registry.
  module ColorSchemes
    class << self
      def color_scheme_registry
        @color_scheme_registry ||= {}
      end

      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

      def [](name)
        color_scheme_registry[name.to_s.strip]
      end
      alias get []

      def names
        color_scheme_registry.keys.sort.dup
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby_jard-0.2.2 lib/ruby_jard/color_schemes.rb