Class: OoxmlParser::DifferentialFormattingRecords

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/xlsx_parser/workbook/style_sheet/differential_formatting_records.rb

Overview

Parsing ‘dxfs` tag

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) ⇒ DifferentialFormattingRecords

Returns a new instance of DifferentialFormattingRecords.



11
12
13
14
# File 'lib/ooxml_parser/xlsx_parser/workbook/style_sheet/differential_formatting_records.rb', line 11

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

Instance Attribute Details

#countInteger (readonly)

Returns count of formats.

Returns:

  • (Integer)

    count of formats



9
10
11
# File 'lib/ooxml_parser/xlsx_parser/workbook/style_sheet/differential_formatting_records.rb', line 9

def count
  @count
end

#differential_formatting_recordsArray, DifferentialFormattingRecord (readonly)

Returns list of formatting records.

Returns:



7
8
9
# File 'lib/ooxml_parser/xlsx_parser/workbook/style_sheet/differential_formatting_records.rb', line 7

def differential_formatting_records
  @differential_formatting_records
end

Instance Method Details

#[](key) ⇒ Array, DifferentialFormattingRecord

Returns accessor.

Returns:



17
18
19
# File 'lib/ooxml_parser/xlsx_parser/workbook/style_sheet/differential_formatting_records.rb', line 17

def [](key)
  @differential_formatting_records[key]
end

#parse(node) ⇒ DifferentialFormattingRecords

Parse DifferentialFormattingRecords data

Parameters:

  • node (Nokogiri::XML:Element)

    with DifferentialFormattingRecords data

Returns:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/ooxml_parser/xlsx_parser/workbook/style_sheet/differential_formatting_records.rb', line 24

def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'count'
      @count = value.value.to_i
    end
  end

  node.xpath('*').each do |node_child|
    case node_child.name
    when 'dxf'
      @differential_formatting_records << DifferentialFormattingRecord.new(parent: self).parse(node_child)
    end
  end
  self
end