Class: OoxmlParser::HeaderFooterChild
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::HeaderFooterChild
- Defined in:
- lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_header_footer/header_footer_child.rb
Overview
Class for parsing header or footer
Instance Attribute Summary collapse
-
#raw_string ⇒ String
readonly
Raw text of header.
-
#type ⇒ Symbol
readonly
Type of header.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#center ⇒ String
Center part of header.
-
#initialize(type: nil, raw_string: nil, parent: nil) ⇒ HeaderFooterChild
constructor
A new instance of HeaderFooterChild.
-
#left ⇒ String
Left part of header.
-
#parse(node) ⇒ HeaderFooterChild
Parse HeaderFooterChild data.
-
#right ⇒ String
Right part of header.
Methods inherited from OOXMLDocumentObject
#==, #boolean_attribute_value, #parse_xml, #with_data?
Methods included from OoxmlObjectAttributeHelper
#attribute_enabled?, #option_enabled?
Methods included from OoxmlDocumentObjectHelper
Constructor Details
#initialize(type: nil, raw_string: nil, parent: nil) ⇒ HeaderFooterChild
Returns a new instance of HeaderFooterChild.
11 12 13 14 15 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_header_footer/header_footer_child.rb', line 11 def initialize(type: nil, raw_string: nil, parent: nil) @type = type @raw_string = raw_string super(parent: parent) end |
Instance Attribute Details
#raw_string ⇒ String (readonly)
Returns raw text of header.
9 10 11 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_header_footer/header_footer_child.rb', line 9 def raw_string @raw_string end |
#type ⇒ Symbol (readonly)
Returns type of header.
7 8 9 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_header_footer/header_footer_child.rb', line 7 def type @type end |
Instance Method Details
#center ⇒ String
Returns center part of header.
36 37 38 39 40 41 42 43 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_header_footer/header_footer_child.rb', line 36 def center return @center if @center center = @raw_string.split('&R').first.match(/&C(.+)/) return nil unless center @center = center[1] end |
#left ⇒ String
Returns left part of header.
46 47 48 49 50 51 52 53 54 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_header_footer/header_footer_child.rb', line 46 def left return @left if @left left = @raw_string.gsub("&R#{right}", '') left = left.gsub("&C#{center}", '') return nil if left == '' left.gsub('&L', '') end |
#parse(node) ⇒ HeaderFooterChild
Parse HeaderFooterChild data
20 21 22 23 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_header_footer/header_footer_child.rb', line 20 def parse(node) @raw_string = node.text self end |
#right ⇒ String
Returns right part of header.
26 27 28 29 30 31 32 33 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/worksheet/xlsx_header_footer/header_footer_child.rb', line 26 def right return @right if @right right = @raw_string.match(/&R(.+)/) return nil unless right @right = right[1] end |