Class: OoxmlParser::ConditionalFormatting

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

Overview

Class for ‘conditionalFormatting` 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) ⇒ ConditionalFormatting

Returns a new instance of ConditionalFormatting.



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

def initialize(parent: nil)
  @rules = []
  super
end

Instance Attribute Details

#reference_sequenceString (readonly)

Returns Ranges to which conditional formatting is applied.

Returns:

  • (String)

    Ranges to which conditional formatting is applied



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

def reference_sequence
  @reference_sequence
end

#rulesArray, ConditionalFormattingRule (readonly)

Returns list of conditional formatting rules.

Returns:



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

def rules
  @rules
end

Instance Method Details

#parse(node) ⇒ ConditionalFormatting

Parse ConditionalFormatting data

Parameters:

  • node (Nokogiri::XML:Element)

    with ConditionalFormatting data

Returns:



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/table_part/extension_list/extension/conditional_formattings/conditional_formatting.rb', line 20

def parse(node)
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'cfRule'
      @rules << ConditionalFormattingRule.new(parent: self).parse(node_child)
    when 'sqref'
      @reference_sequence = node_child.text
    end
  end
  self
end