diff options
| author | Randy Morgan <[email protected]> | 2012-03-27 09:08:06 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-03-27 09:08:06 +0900 |
| commit | 1bbcba13c7f65e725a79cc4b42f258ebe21ca8fa (patch) | |
| tree | 76d8d94c4e6a6b22c1d8c82f5b698e3e1360d6ea /lib/axlsx/stylesheet/color.rb | |
| parent | e64772f7552a4548b5ebb4f42b3fcaa5f4fd1e17 (diff) | |
| download | caxlsx-1bbcba13c7f65e725a79cc4b42f258ebe21ca8fa.tar.gz caxlsx-1bbcba13c7f65e725a79cc4b42f258ebe21ca8fa.zip | |
Some small improvements
total real
axlsx_noautowidth 1.650000 ( 1.684738)
axlsx 4.470000 ( 4.580439)
axlsx_shared 7.990000 ( 8.151813)
axlsx_stream 4.420000 ( 4.435809)
csv 0.250000 ( 0.259114)
Diffstat (limited to 'lib/axlsx/stylesheet/color.rb')
| -rw-r--r-- | lib/axlsx/stylesheet/color.rb | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/lib/axlsx/stylesheet/color.rb b/lib/axlsx/stylesheet/color.rb index 4e9806ad..a4942724 100644 --- a/lib/axlsx/stylesheet/color.rb +++ b/lib/axlsx/stylesheet/color.rb @@ -5,9 +5,9 @@ module Axlsx # Determines if the color is system color dependant # @return [Boolean] attr_reader :auto - - # The color as defined in rgb terms. - # @note + + # 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 @@ -25,16 +25,16 @@ module Axlsx # no support for theme just yet # @return [Integer] #attr_reader :theme - + # The tint value. # @note valid values are between -1.0 and 1.0 # @return [Float] attr_reader :tint - + # Creates a new Color object # @option options [Boolean] auto # @option options [String] rgb - # @option options [Float] tint + # @option options [Float] tint def initialize(options={}) @rgb = "FF000000" options.each do |o| @@ -42,7 +42,7 @@ module Axlsx end end # @see auto - def auto=(v) Axlsx::validate_boolean v; @auto = v end + def auto=(v) Axlsx::validate_boolean v; @auto = v end # @see color def rgb=(v) Axlsx::validate_string(v) @@ -56,11 +56,19 @@ module Axlsx def tint=(v) Axlsx::validate_float v; @tint = v end # This version does not support themes - # def theme=(v) Axlsx::validate_unsigned_integer v; @theme = v end - + # def theme=(v) Axlsx::validate_unsigned_integer v; @theme = v end + # Indexed colors are for backward compatability which I am choosing not to support - # def indexed=(v) Axlsx::validate_unsigned_integer v; @indexed = v end + # def indexed=(v) Axlsx::validate_unsigned_integer v; @indexed = v end + def to_xml_string + str = ["<color "] + str << "tint='%s' " % tint if @tint + str << "rgb='%s' " % rgb if @rgb + str << "auto='%s'" % auto if @auto + str << "/>" + str.join + end # Serializes the color # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to. |
