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
Class Method Summary collapse
-
.default_cfvos ⇒ Object
These are the default conditional formatting value objects that define a two tone color gradient.
-
.three_tone ⇒ Object
A builder for three tone color gradient.
-
.two_tone ⇒ Object
A builder for two tone color gradient.
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.
-
#colors ⇒ SimpleTypedList
A simple types list of colors.
-
#delete_at(index = 2) ⇒ Object
removes the cfvo and color pair at the index specified.
-
#initialize(*cfvos) {|_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(*cfvos) {|_self| ... } ⇒ ColorScale
creates a new ColorScale object.
58 59 60 61 |
# File 'lib/axlsx/workbook/worksheet/color_scale.rb', line 58 def initialize(*cfvos) initialize_default_cfvos(cfvos) yield self if block_given? end |
Class Method Details
.default_cfvos ⇒ Object
These are the default conditional formatting value objects that define a two tone color gradient.
14 15 16 17 |
# File 'lib/axlsx/workbook/worksheet/color_scale.rb', line 14 def default_cfvos [{ type: :min, val: 0, color: 'FFFF7128' }, { type: :max, val: 0, color: 'FFFFEF9C' }] end |
.three_tone ⇒ Object
A builder for three tone color gradient
33 34 35 36 37 |
# File 'lib/axlsx/workbook/worksheet/color_scale.rb', line 33 def three_tone new({ type: :min, val: 0, color: 'FFF8696B' }, { type: :percent, val: '50', color: 'FFFFEB84' }, { type: :max, val: 0, color: 'FF63BE7B' }) end |
.two_tone ⇒ Object
A builder for two tone color gradient
24 25 26 |
# File 'lib/axlsx/workbook/worksheet/color_scale.rb', line 24 def two_tone new 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.
70 71 72 73 74 |
# File 'lib/axlsx/workbook/worksheet/color_scale.rb', line 70 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 |
#colors ⇒ SimpleTypedList
A simple types list of colors
49 50 51 |
# File 'lib/axlsx/workbook/worksheet/color_scale.rb', line 49 def colors @colors ||= SimpleTypedList.new Color 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.
79 80 81 82 |
# File 'lib/axlsx/workbook/worksheet/color_scale.rb', line 79 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
87 88 89 90 91 92 |
# File 'lib/axlsx/workbook/worksheet/color_scale.rb', line 87 def to_xml_string(str = +'') str << '<colorScale>' value_objects.to_xml_string(str) colors.each { |color| color.to_xml_string(str) } str << '</colorScale>' end |