class Xsv::SharedStringsParser
Interpret the sharedStrings.xml file from the workbook This is used internally when opening a sheet.
Public Class Methods
new(&block)
click to toggle source
# File lib/xsv/shared_strings_parser.rb, line 13 def initialize(&block) @block = block @state = nil @skip = false end
parse(io)
click to toggle source
# File lib/xsv/shared_strings_parser.rb, line 7 def self.parse(io) strings = [] new { |s| strings << s }.parse(io) strings end
Public Instance Methods
characters(value)
click to toggle source
# File lib/xsv/shared_strings_parser.rb, line 31 def characters(value) if @state == 't' && !@skip @current_string += value end end
end_element(name)
click to toggle source
# 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)
click to toggle source
# 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