Class: Axlsx::ColorScale
- Inherits:
-
Object
- Object
- Axlsx::ColorScale
- Defined in:
- lib/axlsx/workbook/worksheet/color_scale.rb
Overview
The recommended way to manage these rules is via Worksheet#add_conditional_formatting
Instance Attribute Summary collapse
-
#colors ⇒ SimpleTypedList
readonly
A simple types list of colors.
Instance Method Summary collapse
-
#add(options = {}) ⇒ Hash
adds a new cfvo / color pair to the color scale and returns a hash containing a reference to the newly created cfvo and color objects so you can alter the default properties.
-
#delete_at(index = 2) ⇒ Object
removes the cfvo and color pair at the index specified.
-
#initialize {|_self| ... } ⇒ ColorScale
constructor
creates a new ColorScale object.
-
#to_xml_string(str = '') ⇒ String
Serialize this color_scale object data to an xml string.
-
#value_objects ⇒ SimpleTypedList
A simple typed list of cfvos.
Constructor Details
#initialize {|_self| ... } ⇒ ColorScale
creates a new ColorScale object. This method will yield it self so you can alter the properites of the defauls conditional formating value object (cfvo and colors Two value objects and two colors are created on initialization and cannot be deleted.
27 28 29 30 |
# File 'lib/axlsx/workbook/worksheet/color_scale.rb', line 27 def initialize initialize_colors yield self if block_given? end |
Instance Attribute Details
#colors ⇒ SimpleTypedList (readonly)
A simple types list of colors
20 21 22 |
# File 'lib/axlsx/workbook/worksheet/color_scale.rb', line 20 def colors @colors end |
Instance Method Details
#add(options = {}) ⇒ Hash
adds a new cfvo / color pair to the color scale and returns a hash containing a reference to the newly created cfvo and color objects so you can alter the default properties.
35 36 37 38 39 |
# File 'lib/axlsx/workbook/worksheet/color_scale.rb', line 35 def add(={}) value_objects << Cfvo.new(:type => [:type] || :min, :val => [:val] || 0) @colors << Color.new(:rgb => [:color] || "FF000000") {:cfvo => value_objects.last, :color => @colors.last} end |
#delete_at(index = 2) ⇒ Object
you cannot remove the first two cfvo and color pairs
removes the cfvo and color pair at the index specified.
45 46 47 48 |
# File 'lib/axlsx/workbook/worksheet/color_scale.rb', line 45 def delete_at(index=2) value_objects.delete_at index @colors.delete_at index end |
#to_xml_string(str = '') ⇒ String
Serialize this color_scale object data to an xml string
53 54 55 56 57 58 |
# File 'lib/axlsx/workbook/worksheet/color_scale.rb', line 53 def to_xml_string(str = '') str << '<colorScale>' value_objects.to_xml_string(str) @colors.each { |color| color.to_xml_string(str) } str << '</colorScale>' end |