Class: OoxmlParser::XlsxHeaderFooter

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_header_footer.rb

Overview

Class for parsing <headerFooter> tag

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #initialize, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

This class inherits a constructor from OoxmlParser::OOXMLDocumentObject

Instance Attribute Details

#align_with_marginsSymbol (readonly)

Returns Specifies whether to align header with margins.

Returns:

  • (Symbol)

    Specifies whether to align header with margins



8
9
10
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_header_footer.rb', line 8

def align_with_margins
  @align_with_margins
end

#different_firstSymbol (readonly)

Returns Specifies whether first header is different.

Returns:

  • (Symbol)

    Specifies whether first header is different



10
11
12
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_header_footer.rb', line 10

def different_first
  @different_first
end

#different_odd_evenSymbol (readonly)

Returns Specifies whether odd and even headers are different.

Returns:

  • (Symbol)

    Specifies whether odd and even headers are different



12
13
14
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_header_footer.rb', line 12

def different_odd_even
  @different_odd_even
end

Returns even footer.

Returns:

  • (String)

    even footer



22
23
24
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_header_footer.rb', line 22

def even_footer
  @even_footer
end

#even_headerString (readonly)

Returns even header.

Returns:

  • (String)

    even header



20
21
22
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_header_footer.rb', line 20

def even_header
  @even_header
end

Returns first footer.

Returns:

  • (String)

    first footer



26
27
28
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_header_footer.rb', line 26

def first_footer
  @first_footer
end

#first_headerString (readonly)

Returns first header.

Returns:

  • (String)

    first header



24
25
26
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_header_footer.rb', line 24

def first_header
  @first_header
end

Returns odd footer.

Returns:

  • (String)

    odd footer



18
19
20
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_header_footer.rb', line 18

def odd_footer
  @odd_footer
end

#odd_headerString (readonly)

Returns odd header.

Returns:

  • (String)

    odd header



16
17
18
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_header_footer.rb', line 16

def odd_header
  @odd_header
end

#scale_with_documentSymbol (readonly)

Returns Specifies whether to scale header with document.

Returns:

  • (Symbol)

    Specifies whether to scale header with document



14
15
16
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_header_footer.rb', line 14

def scale_with_document
  @scale_with_document
end

Instance Method Details

#parse(node) ⇒ XlsxHeaderFooter

Parse Header Footer data

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_header_footer.rb', line 31

def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'alignWithMargins'
      @align_with_margins = boolean_attribute_value(value)
    when 'differentFirst'
      @different_first = boolean_attribute_value(value)
    when 'differentOddEven'
      @different_odd_even = boolean_attribute_value(value)
    when 'scaleWithDoc'
      @scale_with_document = boolean_attribute_value(value)
    end

    node.xpath('*').each do |node_child|
      case node_child.name
      when 'oddHeader'
        @odd_header = HeaderFooterChild.new(parent: parent, type: odd_header).parse(node_child)
      when 'oddFooter'
        @odd_footer = HeaderFooterChild.new(parent: parent, type: odd_footer).parse(node_child)
      when 'evenHeader'
        @even_header = HeaderFooterChild.new(parent: parent, type: even_header).parse(node_child)
      when 'evenFooter'
        @even_footer = HeaderFooterChild.new(parent: parent, type: even_footer).parse(node_child)
      when 'firstHeader'
        @first_header = HeaderFooterChild.new(parent: parent, type: first_header).parse(node_child)
      when 'firstFooter'
        @first_footer = HeaderFooterChild.new(parent: parent, type: first_footer).parse(node_child)
      end
    end
  end
  self
end