Class: Saxlsx::SharedStringCollectionParser

Inherits:
Ox::Sax
  • Object
show all
Defined in:
lib/saxlsx/shared_string_collection_parser.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ SharedStringCollectionParser

Returns a new instance of SharedStringCollectionParser.



8
9
10
# File 'lib/saxlsx/shared_string_collection_parser.rb', line 8

def initialize(&block)
  @block = block
end

Class Method Details

.parse(file_system, &block) ⇒ Object



4
5
6
# File 'lib/saxlsx/shared_string_collection_parser.rb', line 4

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

Instance Method Details

#end_element(name) ⇒ Object



16
17
18
19
20
21
# File 'lib/saxlsx/shared_string_collection_parser.rb', line 16

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

#start_element(name) ⇒ Object



12
13
14
# File 'lib/saxlsx/shared_string_collection_parser.rb', line 12

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

#text(value) ⇒ Object



23
24
25
# File 'lib/saxlsx/shared_string_collection_parser.rb', line 23

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