Class: Axlsx::Color
- Inherits:
-
Object
- Object
- Axlsx::Color
- Defined in:
- lib/axlsx/stylesheet/color.rb
Overview
The color class represents a color used for borders, fills an fonts
Instance Attribute Summary collapse
-
#auto ⇒ Boolean
Determines if the color is system color dependant.
-
#rgb ⇒ String
The color as defined in rgb terms.
-
#tint ⇒ Float
The tint value.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Color
constructor
Creates a new Color object.
-
#to_xml_string(str = '') ⇒ String
Serializes the object.
Constructor Details
#initialize(options = {}) ⇒ Color
Creates a new Color object
38 39 40 41 42 43 |
# File 'lib/axlsx/stylesheet/color.rb', line 38 def initialize(={}) @rgb = "FF000000" .each do |o| self.send("#{o[0]}=", o[1]) if self.respond_to? o[0] end end |
Instance Attribute Details
#auto ⇒ Boolean
Determines if the color is system color dependant
7 8 9 |
# File 'lib/axlsx/stylesheet/color.rb', line 7 def auto @auto end |
#rgb ⇒ String
rgb colors need to conform to ST_UnsignedIntHex. That basically means put 'FF' before you color
The color as defined in rgb terms. 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"
23 24 25 |
# File 'lib/axlsx/stylesheet/color.rb', line 23 def rgb @rgb end |
#tint ⇒ Float
valid values are between -1.0 and 1.0
The tint value.
32 33 34 |
# File 'lib/axlsx/stylesheet/color.rb', line 32 def tint @tint end |
Instance Method Details
#to_xml_string(str = '') ⇒ String
Serializes the object
67 68 69 70 71 72 73 |
# File 'lib/axlsx/stylesheet/color.rb', line 67 def to_xml_string(str = '') str << "<color " self.instance_values.each do |key, value| str << key.to_s << '="' << value.to_s << '" ' end str << "/>" end |