class OoxmlParser::HeaderFooterChild
Class for parsing header or footer
Attributes
raw_string[R]
@return [String] raw text of header
type[R]
@return [Symbol] type of header
Public Class Methods
new(type: nil, raw_string: nil, parent: nil)
click to toggle source
Calls superclass method
OoxmlParser::OOXMLDocumentObject::new
# 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
Public Instance Methods
center()
click to toggle source
@return [String] center part of header
# 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()
click to toggle source
@return [String] left part of header
# 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)
click to toggle source
Parse HeaderFooterChild
data @param node [Nokogiri::XML:Element] node to parse @return [HeaderFooterChild] result of parsing
# 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()
click to toggle source
@return [String] right part of header
# 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