Sha256: f36d9e507fb0591ddb82210030a8e564924653b1e840ac05b16c6b26e884567e

Contents?: true

Size: 567 Bytes

Versions: 4

Compression:

Stored size: 567 Bytes

Contents

class ASE
  class Palette
    attr_accessor :name, :colors

    def initialize(name)
      @name = name
      @colors = {}
    end

    def add(name, color)
      @colors[name] = color
    end
    alias :[]= :add
    alias :add_color :add

    def remove(name)
      @colors.delete(name)
    end

    def [](i)
      @colors[i]
    end

    def length
      @colors.length
    end
    alias :size :length

    def method_missing(method, *args, &block)
      if @colors.has_key?(method.to_s)
        return @colors[method.to_s]
      end

      super
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ase-1.0.3 lib/ase/palette.rb
ase-1.0.2 lib/ase/palette.rb
ase-1.0.1 lib/ase/palette.rb
ase-1.0.0 lib/ase/palette.rb