Class: OoxmlParser::ConditionalFormattingRule
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::ConditionalFormattingRule
- Defined in:
- lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb
Overview
Class for ‘cfRule` data
Instance Attribute Summary collapse
-
#above_average ⇒ Boolean
readonly
Specifies whether rule highlights values above average.
-
#bottom ⇒ Symbol
readonly
Specifies whether top/bottom rule highlights bottom values.
-
#color_scale ⇒ ColorScale
readonly
Color scale formatting.
-
#data_bar ⇒ DataBar
readonly
Data bar formatting.
-
#equal_average ⇒ Boolean
readonly
Specifies whether rule highlights values equal to average.
-
#format_index ⇒ Integer
readonly
Index of format.
-
#formulas ⇒ Array<Formula>
readonly
Formulas to determine condition.
-
#icon_set ⇒ IconSet
readonly
Icon set formatting.
-
#id ⇒ String
readonly
ID of rule.
-
#operator ⇒ Symbol
readonly
Relational operator in value rule.
-
#percent ⇒ Symbol
readonly
Specifies whether percent is used in top/bottom rule.
-
#priority ⇒ Integer
readonly
Specifies position on the list of rules.
-
#rank ⇒ Integer
readonly
Number of items in top/bottom rule.
-
#rule_format ⇒ DifferentialFormattingRecord
readonly
Format.
-
#standard_deviation ⇒ Integer
readonly
Number of standard deviations in above/below average rule.
-
#stop_if_true ⇒ Symbol
readonly
Specifies whether rules with lower priority should be applied over this rule.
-
#text ⇒ String
readonly
Text value in text rule.
-
#time_period ⇒ Symbol
readonly
Time period in date rule.
-
#type ⇒ Symbol
readonly
Type of rule.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#format ⇒ nil, DifferentialFormattingRecord
Format of rule.
-
#initialize(parent: nil) ⇒ ConditionalFormattingRule
constructor
A new instance of ConditionalFormattingRule.
-
#parse(node) ⇒ ConditionalFormattingRule
Parse ConditionalFormattingRule data.
Methods inherited from OOXMLDocumentObject
#==, #boolean_attribute_value, #parse_xml, #with_data?
Methods included from OoxmlObjectAttributeHelper
#attribute_enabled?, #option_enabled?
Methods included from OoxmlDocumentObjectHelper
Constructor Details
#initialize(parent: nil) ⇒ ConditionalFormattingRule
Returns a new instance of ConditionalFormattingRule.
49 50 51 52 53 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 49 def initialize(parent: nil) @above_average = true @formulas = [] super end |
Instance Attribute Details
#above_average ⇒ Boolean (readonly)
Returns Specifies whether rule highlights values above average.
29 30 31 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 29 def above_average @above_average end |
#bottom ⇒ Symbol (readonly)
Returns Specifies whether top/bottom rule highlights bottom values.
23 24 25 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 23 def bottom @bottom end |
#color_scale ⇒ ColorScale (readonly)
Returns color scale formatting.
45 46 47 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 45 def color_scale @color_scale end |
#data_bar ⇒ DataBar (readonly)
Returns data bar formatting.
43 44 45 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 43 def @data_bar end |
#equal_average ⇒ Boolean (readonly)
Returns Specifies whether rule highlights values equal to average.
31 32 33 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 31 def equal_average @equal_average end |
#format_index ⇒ Integer (readonly)
Returns index of format.
17 18 19 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 17 def format_index @format_index end |
#formulas ⇒ Array<Formula> (readonly)
Returns Formulas to determine condition.
39 40 41 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 39 def formulas @formulas end |
#icon_set ⇒ IconSet (readonly)
Returns icon set formatting.
47 48 49 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 47 def icon_set @icon_set end |
#id ⇒ String (readonly)
Returns ID of rule.
15 16 17 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 15 def id @id end |
#operator ⇒ Symbol (readonly)
Returns Relational operator in value rule.
21 22 23 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 21 def operator @operator end |
#percent ⇒ Symbol (readonly)
Returns Specifies whether percent is used in top/bottom rule.
25 26 27 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 25 def percent @percent end |
#priority ⇒ Integer (readonly)
Returns Specifies position on the list of rules.
13 14 15 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 13 def priority @priority end |
#rank ⇒ Integer (readonly)
Returns Number of items in top/bottom rule.
27 28 29 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 27 def rank @rank end |
#rule_format ⇒ DifferentialFormattingRecord (readonly)
Returns Format.
41 42 43 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 41 def rule_format @rule_format end |
#standard_deviation ⇒ Integer (readonly)
Returns Number of standard deviations in above/below average rule.
33 34 35 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 33 def standard_deviation @standard_deviation end |
#stop_if_true ⇒ Symbol (readonly)
Returns Specifies whether rules with lower priority should be applied over this rule.
19 20 21 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 19 def stop_if_true @stop_if_true end |
#text ⇒ String (readonly)
Returns Text value in text rule.
35 36 37 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 35 def text @text end |
#time_period ⇒ Symbol (readonly)
Returns Time period in date rule.
37 38 39 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 37 def time_period @time_period end |
#type ⇒ Symbol (readonly)
Returns Type of rule.
11 12 13 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 11 def type @type end |
Instance Method Details
#format ⇒ nil, DifferentialFormattingRecord
Returns format of rule.
110 111 112 113 114 115 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 110 def format return @rule_format if @rule_format return nil unless @format_index root_object.style_sheet.differential_formatting_records[@format_index] end |
#parse(node) ⇒ ConditionalFormattingRule
Parse ConditionalFormattingRule data
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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting/conditional_formatting_rule.rb', line 58 def parse(node) node.attributes.each do |key, value| case key when 'type' @type = value.value.to_sym when 'priority' @priority = value.value.to_i when 'id' @id = value.value.to_s when 'dxfId' @format_index = value.value.to_i when 'stopIfTrue' @stop_if_true = attribute_enabled?(value) when 'operator' @operator = value.value.to_sym when 'bottom' @bottom = attribute_enabled?(value) when 'percent' @percent = attribute_enabled?(value) when 'rank' @rank = value.value.to_i when 'aboveAverage' @above_average = attribute_enabled?(value) when 'equalAverage' @equal_average = attribute_enabled?(value) when 'stdDev' @standard_deviation = value.value.to_i when 'text' @text = value.text.to_s when 'timePeriod' @time_period = value.value.to_sym end end node.xpath('*').each do |node_child| case node_child.name when 'f' @formulas << Formula.new(parent: self).parse(node_child) when 'dxf' @rule_format = DifferentialFormattingRecord.new(parent: self).parse(node_child) when 'dataBar' @data_bar = DataBar.new(parent: self).parse(node_child) when 'colorScale' @color_scale = ColorScale.new(parent: self).parse(node_child) when 'iconSet' @icon_set = IconSet.new(parent: self).parse(node_child) end end self end |