Class: OoxmlParser::DataBar

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/data_bar.rb

Overview

Class for ‘dataBar` data

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(parent: nil) ⇒ DataBar

Returns a new instance of DataBar.



38
39
40
41
42
43
44
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/data_bar.rb', line 38

def initialize(parent: nil)
  @values = []
  @show_value = true
  @gradient = true
  @negative_border_same_as_positive = true
  super
end

Instance Attribute Details

#axis_colorColor (readonly)

Returns Axis color.

Returns:



36
37
38
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/data_bar.rb', line 36

def axis_color
  @axis_color
end

#axis_positionSymbol (readonly)

Returns Position of axis in a cell.

Returns:

  • (Symbol)

    Position of axis in a cell



14
15
16
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/data_bar.rb', line 14

def axis_position
  @axis_position
end

#borderSymbol (readonly)

Returns Specifies whether data bar has border.

Returns:

  • (Symbol)

    Specifies whether data bar has border



20
21
22
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/data_bar.rb', line 20

def border
  @border
end

#border_colorColor (readonly)

Returns Border color for positive values.

Returns:

  • (Color)

    Border color for positive values



32
33
34
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/data_bar.rb', line 32

def border_color
  @border_color
end

#directionSymbol (readonly)

Returns Data bar direction.

Returns:

  • (Symbol)

    Data bar direction



16
17
18
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/data_bar.rb', line 16

def direction
  @direction
end

#fill_colorColor (readonly)

Returns Fill color for positive values.

Returns:

  • (Color)

    Fill color for positive values



28
29
30
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/data_bar.rb', line 28

def fill_color
  @fill_color
end

#gradientSymbol (readonly)

Returns Specifies whether data bar fill is gradient.

Returns:

  • (Symbol)

    Specifies whether data bar fill is gradient



18
19
20
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/data_bar.rb', line 18

def gradient
  @gradient
end

#max_lengthInteger (readonly)

Returns Maximal length of the data bar as a percentage of the cell width.

Returns:

  • (Integer)

    Maximal length of the data bar as a percentage of the cell width



10
11
12
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/data_bar.rb', line 10

def max_length
  @max_length
end

#min_lengthInteger (readonly)

Returns Minimal length of the data bar as a percentage of the cell width.

Returns:

  • (Integer)

    Minimal length of the data bar as a percentage of the cell width



8
9
10
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/data_bar.rb', line 8

def min_length
  @min_length
end

#negative_bar_same_as_positiveSymbol (readonly)

Returns Specifies whether fill color for negative values is same as for positive.

Returns:

  • (Symbol)

    Specifies whether fill color for negative values is same as for positive



22
23
24
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/data_bar.rb', line 22

def negative_bar_same_as_positive
  @negative_bar_same_as_positive
end

#negative_border_colorColor (readonly)

Returns Border color for negative values.

Returns:

  • (Color)

    Border color for negative values



34
35
36
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/data_bar.rb', line 34

def negative_border_color
  @negative_border_color
end

#negative_border_same_as_positiveSymbol (readonly)

Returns Specifies whether border color for negative values is same as for positive.

Returns:

  • (Symbol)

    Specifies whether border color for negative values is same as for positive



24
25
26
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/data_bar.rb', line 24

def negative_border_same_as_positive
  @negative_border_same_as_positive
end

#negative_fill_colorColor (readonly)

Returns Fill color for negative values.

Returns:

  • (Color)

    Fill color for negative values



30
31
32
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/data_bar.rb', line 30

def negative_fill_color
  @negative_fill_color
end

#show_valueSymbol (readonly)

Returns Specifies whether value is shown in a cell.

Returns:

  • (Symbol)

    Specifies whether value is shown in a cell



12
13
14
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/data_bar.rb', line 12

def show_value
  @show_value
end

#valuesArray, ConditionalFormatValueObject (readonly)

Returns minimal and maximal value.

Returns:



26
27
28
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/data_bar.rb', line 26

def values
  @values
end

Instance Method Details

#maximumConditionalFormatValueObject

Returns maximal value.

Returns:



98
99
100
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/data_bar.rb', line 98

def maximum
  values[1]
end

#minimumConditionalFormatValueObject

Returns minimal value.

Returns:



93
94
95
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/data_bar.rb', line 93

def minimum
  values[0]
end

#parse(node) ⇒ DataBar

Parse DataBar data

Parameters:

  • node (Nokogiri::XML:Element)

    with DataBar data

Returns:

  • (DataBar)

    value of DataBar data



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule/data_bar.rb', line 49

def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'minLength'
      @min_length = value.value.to_i
    when 'maxLength'
      @max_length = value.value.to_i
    when 'showValue'
      @show_value = attribute_enabled?(value)
    when 'axisPosition'
      @axis_position = value.value.to_sym
    when 'direction'
      @direction = value.value.to_sym
    when 'gradient'
      @gradient = attribute_enabled?(value)
    when 'border'
      @border = attribute_enabled?(value)
    when 'negativeBarColorSameAsPositive'
      @negative_bar_same_as_positive = attribute_enabled?(value)
    when 'negativeBarBorderColorSameAsPositive'
      @negative_border_same_as_positive = attribute_enabled?(value)
    end
  end

  node.xpath('*').each do |node_child|
    case node_child.name
    when 'cfvo'
      @values << ConditionalFormatValueObject.new(parent: self).parse(node_child)
    when 'fillColor'
      @fill_color = OoxmlColor.new(parent: self).parse(node_child)
    when 'negativeFillColor'
      @negative_fill_color = OoxmlColor.new(parent: self).parse(node_child)
    when 'borderColor'
      @border_color = OoxmlColor.new(parent: self).parse(node_child)
    when 'negativeBorderColor'
      @negative_border_color = OoxmlColor.new(parent: self).parse(node_child)
    when 'axisColor'
      @axis_color = OoxmlColor.new(parent: self).parse(node_child)
    end
  end
  self
end