Class: Axlsx::IconSet

Inherits:
Object
  • Object
show all
Defined in:
lib/axlsx/workbook/worksheet/icon_set.rb

Overview

Note:

The recommended way to manage these rules is via Worksheet#add_conditional_formatting

Constant Summary collapse

CHILD_ELEMENTS =

instance values that must be serialized as their own elements - e.g. not attributes.

[:value_objects]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ IconSet

Creates a new icon set object

Parameters:

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

    a customizable set of options

Options Hash (options):

  • iconSet (String)
  • reverse (Boolean)
  • percent (Boolean)
  • showValue (Boolean)

Yields:

  • (_self)

Yield Parameters:



39
40
41
42
43
44
45
46
47
48
# File 'lib/axlsx/workbook/worksheet/icon_set.rb', line 39

def initialize(options = {})
  @percent = @showValue = true
  @reverse = false
  @iconSet = "3TrafficLights1"
  initialize_value_objects
  options.each do |o|
    self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
  end
  yield self if block_given?
end

Instance Attribute Details

#iconSetString

The icon set to display. Allowed values are: 3Arrows, 3ArrowsGray, 3Flags, 3TrafficLights1, 3TrafficLights2, 3Signs, 3Symbols, 3Symbols2, 4Arrows, 4ArrowsGray, 4RedToBlack, 4Rating, 4TrafficLights, 5Arrows, 5ArrowsGray, 5Rating, 5Quarters The default value is 3TrafficLights1

Returns:

  • (String)


17
18
19
# File 'lib/axlsx/workbook/worksheet/icon_set.rb', line 17

def iconSet
  @iconSet
end

#percentBoolean

Indicates whether the thresholds indicate percentile values, instead of number values. The default falue is true

Returns:

  • (Boolean)


22
23
24
# File 'lib/axlsx/workbook/worksheet/icon_set.rb', line 22

def percent
  @percent
end

#reverseBoolean

If true, reverses the default order of the icons in this icon set.maxLength attribute The default value is false

Returns:

  • (Boolean)


27
28
29
# File 'lib/axlsx/workbook/worksheet/icon_set.rb', line 27

def reverse
  @reverse
end

#showValueBoolean

Indicates whether to show the values of the cells on which this data bar is applied. The default value is true

Returns:

  • (Boolean)


32
33
34
# File 'lib/axlsx/workbook/worksheet/icon_set.rb', line 32

def showValue
  @showValue
end

Instance Method Details

#to_xml_string(str = "") ⇒ String

Serialize this object to an xml string

Parameters:

  • str (String) (defaults to: "")

Returns:

  • (String)


65
66
67
68
69
70
71
# File 'lib/axlsx/workbook/worksheet/icon_set.rb', line 65

def to_xml_string(str="")
  str << '<iconSet '
  str << instance_values.map { |key, value| '' << key << '="' << value.to_s << '"' unless CHILD_ELEMENTS.include?(key.to_sym) }.join(' ')
  str << '>'
  @value_objects.each { |cfvo| cfvo.to_xml_string(str) }
  str << '</iconSet>'
end