Class: Xsv::SharedStringsParser
Overview
Interpret the sharedStrings.xml file from the workbook This is used internally when opening a sheet.
Constant Summary
Constants inherited
from SaxParser
Xsv::SaxParser::ATTR_REGEX
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from SaxParser
#parse
Constructor Details
Returns a new instance of SharedStringsParser.
13
14
15
16
17
|
# File 'lib/xsv/shared_strings_parser.rb', line 13
def initialize(&block)
@block = block
@state = nil
@skip = false
end
|
Class Method Details
.parse(io) ⇒ Object
7
8
9
10
11
|
# File 'lib/xsv/shared_strings_parser.rb', line 7
def self.parse(io)
strings = []
new { |s| strings << -s }.parse(io)
strings
end
|
Instance Method Details
#characters(value) ⇒ Object
31
32
33
34
35
|
# File 'lib/xsv/shared_strings_parser.rb', line 31
def characters(value)
if @state == "t" && !@skip
@current_string += value
end
end
|
#end_element(name) ⇒ Object
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/xsv/shared_strings_parser.rb', line 37
def end_element(name)
case name
when "si"
@block.call(@current_string)
when "rPh"
@skip = false
when "t"
@state = nil
end
end
|
#start_element(name, _attrs) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/xsv/shared_strings_parser.rb', line 19
def start_element(name, _attrs)
case name
when "si"
@current_string = ""
@skip = false
when "rPh"
@skip = true
when "t"
@state = name
end
end
|