Sha256: c408620b4cf4d2dd6260c4c8149aff8547bd02a4a299790adba8c4f390ef5ae6

Contents?: true

Size: 552 Bytes

Versions: 3

Compression:

Stored size: 552 Bytes

Contents

module Saxlsx
  class SharedStringCollectionParser < Ox::Sax

    def self.parse(file_system, &block)
      SaxParser.parse self.new(&block), file_system.shared_strings
    end

    def initialize(&block)
      @block = block
    end

    def start_element(name)
      @current_string = '' if name == :si
    end

    def end_element(name)
      if name == :si
        @block.call @current_string
        @current_string = nil
      end
    end

    def text(value)
      @current_string << CGI.unescapeHTML(value) if @current_string
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
saxlsx-0.3.0 lib/saxlsx/shared_string_collection_parser.rb
saxlsx-0.2.0 lib/saxlsx/shared_string_collection_parser.rb
saxlsx-0.1.0 lib/saxlsx/shared_string_collection_parser.rb