module Axlsx::Parser

The Parser module mixes in a number of methods to help in generating a model from xml This module is not included in the axlsx library at this time. It is for future development only,

Attributes

parser_xml[RW]

The xml to be parsed

Public Instance Methods

parse_float(attr_name, xpath) click to toggle source

parse, convert and assign node text to float

# File lib/axlsx/util/parser.rb, line 30
def parse_float attr_name, xpath
  v = parse_value xpath
  v = v.to_f if v.respond_to?(:to_f)
  send("#{attr_name.to_s}=", v)
end
parse_integer(attr_name, xpath) click to toggle source

parse, convert and assign note text to integer

# File lib/axlsx/util/parser.rb, line 23
def parse_integer attr_name, xpath
  v = parse_value xpath
  v = v.to_i if v.respond_to?(:to_i)
  send("#{attr_name.to_s}=", v)
end
parse_string(attr_name, xpath) click to toggle source

parse and assign string attribute

# File lib/axlsx/util/parser.rb, line 11
def parse_string attr_name, xpath
  send("#{attr_name.to_s}=", parse_value(xpath))
end
parse_symbol(attr_name, xpath) click to toggle source

parse convert and assign node text to symbol

# File lib/axlsx/util/parser.rb, line 16
def parse_symbol attr_name, xpath
  v = parse_value xpath
  v = v.to_sym unless v.nil?
  send("#{attr_name.to_s}=", v)
end
parse_value(xpath) click to toggle source

return node text based on xpath

# File lib/axlsx/util/parser.rb, line 37
def parse_value xpath
  node = parser_xml.xpath(xpath)
  return nil if node.empty?
  node.text.strip
end