Class: Axlsx::Color

Inherits:
Object
  • Object
show all
Defined in:
lib/axlsx/stylesheet/color.rb

Overview

The color class represents a color used for borders, fills an fonts

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Color

Creates a new Color object

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • auto (Boolean)
  • rgb (String)
  • tint (Float)


34
35
36
37
38
39
# File 'lib/axlsx/stylesheet/color.rb', line 34

def initialize(options={})
  @rgb = "FF000000"
  options.each do |o|
    self.send("#{o[0]}=", o[1]) if self.respond_to? o[0]
  end
end

Instance Attribute Details

#autoBoolean

Determines if the color is system color dependant

Returns:

  • (Boolean)


6
7
8
# File 'lib/axlsx/stylesheet/color.rb', line 6

def auto
  @auto
end

#rgbString

Note:

rgb colors need to conform to ST_UnsignedIntHex. That basically means put ‘FF’ before you color

The color as defined in rgb terms.

Examples:

rgb colors

"FF000000" is black
"FFFFFFFF" is white

Returns:

  • (String)


19
20
21
# File 'lib/axlsx/stylesheet/color.rb', line 19

def rgb
  @rgb
end

#tintFloat

Note:

valid values are between -1.0 and 1.0

The tint value.

Returns:

  • (Float)


28
29
30
# File 'lib/axlsx/stylesheet/color.rb', line 28

def tint
  @tint
end

Instance Method Details

#to_xml(xml) ⇒ String

Serializes the color

Parameters:

  • xml (Nokogiri::XML::Builder)

    The document builder instance this objects xml will be added to.

Returns:

  • (String)


55
# File 'lib/axlsx/stylesheet/color.rb', line 55

def to_xml(xml) xml.color(self.instance_values) end