Sha256: 3fbb591a0a7de65c3c9af25fa6482d7f6a4c7333706c95c91b028a487350912e

Contents?: true

Size: 714 Bytes

Versions: 3

Compression:

Stored size: 714 Bytes

Contents

require 'rubyXL/objects/ooxml_object'

module RubyXL

  # http://www.datypic.com/sc/ooxml/e-ssml_color-4.html
  class Color < OOXMLObject
    COLOR_REGEXP = /\A([a-f]|[A-F]|[0-9]){6}\Z/

    define_attribute(:auto,    :bool)
    define_attribute(:indexed, :uint)
    define_attribute(:rgb,     ST_UnsignedIntHex)
    define_attribute(:theme,   :uint)
    define_attribute(:tint,    :double, :default => 0.0)
    define_element_name 'color'

    #validates hex color code, no '#' allowed
    def self.validate_color(color)
      if color =~ COLOR_REGEXP
        return true
      else
        raise 'invalid color'
      end
    end

    include ColorConvenienceMethods
  end

  include ColorConvenienceClasses
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubyXL-3.3.33 lib/rubyXL/objects/color.rb
rubyXL-3.3.31 lib/rubyXL/objects/color.rb
rubyXL-3.3.30 lib/rubyXL/objects/color.rb