Class: OoxmlParser::Fills

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills.rb

Overview

Parsing ‘fonts` tag

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, add_to_xmls_stack, copy_file_and_rename_to_zip, current_xml, dir, encrypted_file?, get_link_from_rels, unzip_file, #with_data?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(parent: nil) ⇒ Fills

Returns a new instance of Fills.



8
9
10
11
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills.rb', line 8

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

Instance Attribute Details

#fills_arrayArray, Fill

Returns array of fills.

Returns:

  • (Array, Fill)

    array of fills



6
7
8
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills.rb', line 6

def fills_array
  @fills_array
end

Instance Method Details

#[](key) ⇒ Array, Fill

Returns accessor.

Returns:

  • (Array, Fill)

    accessor



14
15
16
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills.rb', line 14

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

#parse(node) ⇒ Fills

Parse Fills data

Parameters:

  • node (Nokogiri::XML:Element)

    with Fills data

Returns:

  • (Fills)

    value of Fills data



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/style_sheet/fills.rb', line 21

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 'fill'
      @fills_array << Fill.new(parent: self).parse(node_child)
    end
  end
  self
end