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.
-
#value_objects ⇒ SimpleTypedList
readonly
A simple typed list of cfvos.
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.
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.
25 26 27 28 29 |
# File 'lib/axlsx/workbook/worksheet/color_scale.rb', line 25 def initialize initialize_value_objects initialize_colors yield self if block_given? end |
Instance Attribute Details
#colors ⇒ SimpleTypedList (readonly)
A simple types list of colors
18 19 20 |
# File 'lib/axlsx/workbook/worksheet/color_scale.rb', line 18 def colors @colors end |
#value_objects ⇒ SimpleTypedList (readonly)
A simple typed list of cfvos
13 14 15 |
# File 'lib/axlsx/workbook/worksheet/color_scale.rb', line 13 def value_objects @value_objects 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.
34 35 36 37 38 |
# File 'lib/axlsx/workbook/worksheet/color_scale.rb', line 34 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.
44 45 46 47 |
# File 'lib/axlsx/workbook/worksheet/color_scale.rb', line 44 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
52 53 54 55 56 57 |
# File 'lib/axlsx/workbook/worksheet/color_scale.rb', line 52 def to_xml_string(str = '') str << '<colorScale>' @value_objects.each { |cfvo| cfvo.to_xml_string(str) } @colors.each { |color| color.to_xml_string(str) } str << '</colorScale>' end |