From 78de4578651503bf9fa8cc8028ac0192eb8b448d Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Mon, 5 Dec 2011 14:19:12 +0900 Subject: updating docs and examples --- lib/axlsx/util/constants.rb | 1 + lib/axlsx/util/parser.rb | 12 ++++++++++-- lib/axlsx/workbook/workbook.rb | 2 +- lib/axlsx/workbook/worksheet/worksheet.rb | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/axlsx/util/constants.rb b/lib/axlsx/util/constants.rb index e7bfca88..b0a81eac 100644 --- a/lib/axlsx/util/constants.rb +++ b/lib/axlsx/util/constants.rb @@ -211,5 +211,6 @@ module Axlsx # error message for RegexValidator ERR_REGEX = "Invalid Data. %s does not match %s." + # error message for duplicate sheet names ERR_DUPLICATE_SHEET_NAME = "There is already a worksheet in this workbook named '%s'. Please use a unique name" end diff --git a/lib/axlsx/util/parser.rb b/lib/axlsx/util/parser.rb index 68523ebf..049c2d43 100644 --- a/lib/axlsx/util/parser.rb +++ b/lib/axlsx/util/parser.rb @@ -1,30 +1,38 @@ module Axlsx # 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, module Parser - attr_accessor :parser_xml + # The xml to be parsed + attr_accessor :parser_xml + + # parse and assign string attribute def parse_string attr_name, xpath send("#{attr_name.to_s}=", parse_value(xpath)) end + # parse convert and assign node text to symbol 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, convert and assign note text to integer 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, convert and assign node text to float 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 - + + # return node text based on xpath def parse_value xpath node = parser_xml.xpath(xpath) return nil if node.empty? diff --git a/lib/axlsx/workbook/workbook.rb b/lib/axlsx/workbook/workbook.rb index b1cbac89..4d55ad1e 100644 --- a/lib/axlsx/workbook/workbook.rb +++ b/lib/axlsx/workbook/workbook.rb @@ -130,7 +130,7 @@ require 'axlsx/workbook/worksheet/worksheet.rb' end # returns a range of cells in a worksheet - # @params [String] cell_def The excel style reference defining the worksheet and cells. The range must specify the sheet to + # @param [String] cell_def The excel style reference defining the worksheet and cells. The range must specify the sheet to # retrieve the cells from. e.g. range('Sheet1!A1:B2') will return an array of four cells [A1, A2, B1, B2] while range('Sheet1!A1') will return a single Cell. # @return [Cell, Array] def [](cell_def) diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb index 8f285380..8cbf876f 100644 --- a/lib/axlsx/workbook/worksheet/worksheet.rb +++ b/lib/axlsx/workbook/worksheet/worksheet.rb @@ -44,7 +44,7 @@ module Axlsx # Returns the cell or cells defined using excel style A1:B3 references. # @param [String] cell_def the string defining the cell or range of cells - # @returns [Cell, Array] + # @return [Cell, Array] def [](cell_def) parts = cell_def.split(':') first = name_to_cell parts[0] -- cgit v1.2.3