caxlsx 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,44 +0,0 @@
1
- # encoding: UTF-8
2
- module Axlsx
3
- # The Parser module mixes in a number of methods to help in generating a model from xml
4
- # This module is not included in the axlsx library at this time. It is for future development only,
5
- module Parser
6
-
7
- # The xml to be parsed
8
- attr_accessor :parser_xml
9
-
10
- # parse and assign string attribute
11
- def parse_string attr_name, xpath
12
- send("#{attr_name}=", parse_value(xpath))
13
- end
14
-
15
- # parse convert and assign node text to symbol
16
- def parse_symbol attr_name, xpath
17
- v = parse_value xpath
18
- v = v.to_sym unless v.nil?
19
- send("#{attr_name}=", v)
20
- end
21
-
22
- # parse, convert and assign note text to integer
23
- def parse_integer attr_name, xpath
24
- v = parse_value xpath
25
- v = v.to_i if v.respond_to?(:to_i)
26
- send("#{attr_name}=", v)
27
- end
28
-
29
- # parse, convert and assign node text to float
30
- def parse_float attr_name, xpath
31
- v = parse_value xpath
32
- v = v.to_f if v.respond_to?(:to_f)
33
- send("#{attr_name}=", v)
34
- end
35
-
36
- # return node text based on xpath
37
- def parse_value xpath
38
- node = parser_xml.xpath(xpath)
39
- return nil if node.empty?
40
- node.text.strip
41
- end
42
-
43
- end
44
- end