Sha256: 5c88342b9c3d6acac691bd9aa54d88a0d81553e2e484f6b6084c08e434595e40

Contents?: true

Size: 687 Bytes

Versions: 5

Compression:

Stored size: 687 Bytes

Contents

# frozen_string_literal: true
module Saxlsx
  class SharedStringCollectionParser < Ox::Sax

    def self.parse(file_system, &block)
      shared_strings = file_system.shared_strings
      if shared_strings
        SaxParser.parse self.new(&block), shared_strings
      else
        []
      end
    end

    def initialize(&block)
      @block = block
    end

    def start_element(name)
      @current_string = String.new 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

5 entries across 5 versions & 1 rubygems

Version Path
saxlsx-1.11.0 lib/saxlsx/shared_string_collection_parser.rb
saxlsx-1.10.0 lib/saxlsx/shared_string_collection_parser.rb
saxlsx-1.9.0 lib/saxlsx/shared_string_collection_parser.rb
saxlsx-1.8.0 lib/saxlsx/shared_string_collection_parser.rb
saxlsx-1.7.1 lib/saxlsx/shared_string_collection_parser.rb