Class: OoxmlParser::RowFields

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/row_fields.rb

Overview

Class for parsing <rowFields> 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) ⇒ RowFields

Returns a new instance of RowFields.



13
14
15
16
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/row_fields.rb', line 13

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

Instance Attribute Details

#countInteger (readonly)

Returns count.

Returns:

  • (Integer)

    count



9
10
11
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/row_fields.rb', line 9

def count
  @count
end

#fieldsArray<Field> (readonly)

Returns list of Field object.

Returns:

  • (Array<Field>)

    list of Field object



11
12
13
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/row_fields.rb', line 11

def fields
  @fields
end

Instance Method Details

#[](key) ⇒ Field

Returns accessor.

Returns:



19
20
21
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/row_fields.rb', line 19

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

#parse(node) ⇒ RowFields

Parse ‘<rowFields>` tag

Parameters:

  • node (Nokogiri::XML:Element)

    with rowFields data

Returns:



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/row_fields.rb', line 26

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 'field'
      @fields << Field.new(parent: self).parse(node_child)
    end
  end
  self
end