Sha256: 01fea7ab5054a1022e9e2549d6d16503cc4b8f3af5d9cdf6cbae2c490590e37f

Contents?: true

Size: 694 Bytes

Versions: 6

Compression:

Stored size: 694 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-f0-9]{6}|[a-f0-9]{8})\Z/i

    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

6 entries across 6 versions & 1 rubygems

Version Path
rubyXL-3.4.33 lib/rubyXL/objects/color.rb
rubyXL-3.4.32 lib/rubyXL/objects/color.rb
rubyXL-3.4.31 lib/rubyXL/objects/color.rb
rubyXL-3.4.30 lib/rubyXL/objects/color.rb
rubyXL-3.4.29 lib/rubyXL/objects/color.rb
rubyXL-3.4.28 lib/rubyXL/objects/color.rb