class Axlsx::Color
The color class represents a color used for borders, fills an fonts
Attributes
Determines if the color is system color dependant @return [Boolean]
The color as defined in rgb terms. @note
rgb colors need to conform to ST_UnsignedIntHex. That basically means put 'FF' before you color
When assigning the rgb value the behavior is much like CSS selectors and can use shorthand versions as follows: If you provide a two character value it will be repeated for each r, g, b assignment If you provide data that is not 2 characters in length, and is less than 8 characters it will be padded with âFâ @example
Color.new :rgb => "FF000000" => #<Axlsx::Color:0x102106b68 @rgb="FF000000"> Color.new :rgb => "0A" => #<Axlsx::Color:0x102106b68 @rgb="FF0A0A0A"> Color.new :rgb => "00BB" => #<Axlsx::Color:0x102106b68 @rgb="FFFF00BB">
@return [String]
The tint value. @note valid values are between -1.0 and 1.0 @return [Float]
Public Class Methods
Creates a new Color
object @option options [Boolean] auto @option options [String] rgb @option options [Float] tint
# File lib/axlsx/stylesheet/color.rb, line 13 def initialize(options={}) @rgb = "FF000000" parse_options options end
Public Instance Methods
@see auto
# File lib/axlsx/stylesheet/color.rb, line 50 def auto=(v) Axlsx::validate_boolean v; @auto = v end
@see color
# File lib/axlsx/stylesheet/color.rb, line 52 def rgb=(v) Axlsx::validate_string(v) v = v.upcase v = v * 3 if v.size == 2 v = v.rjust(8, 'FF') raise ArgumentError, "Invalid color rgb value: #{v}." unless v.match(/[0-9A-F]{8}/) @rgb = v end
@see tint
# File lib/axlsx/stylesheet/color.rb, line 61 def tint=(v) Axlsx::validate_float v; @tint = v end
Serializes the object @param [String] str @return [String]
# File lib/axlsx/stylesheet/color.rb, line 72 def to_xml_string(str = '', tag_name = 'color') serialized_tag('' + tag_name + '', str) end