Sha256: 3c9f28270d4fafcc996f7eebe9363a7a3b6f8f7a719c72ef5b6609ec7b559d2c

Contents?: true

Size: 688 Bytes

Versions: 4

Compression:

Stored size: 688 Bytes

Contents

require 'rubyXL/objects/ooxml_object'
require 'rubyXL/objects/simple_types'

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,     RubyXL::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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubyXL-3.4.27 lib/rubyXL/objects/color.rb
rubyXL-3.4.26 lib/rubyXL/objects/color.rb
rubyXL-3.4.25 lib/rubyXL/objects/color.rb
rubyXL-3.4.24 lib/rubyXL/objects/color.rb