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.



14
15
16
# File 'lib/saxlsx/shared_string_collection_parser.rb', line 14

def initialize(&block)
  @block = block
end

Class Method Details

.parse(file_system, &block) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/saxlsx/shared_string_collection_parser.rb', line 5

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

Instance Method Details

#end_element(name) ⇒ Object



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

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

#start_element(name) ⇒ Object



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

def start_element(name)
  @current_string = String.new if name == :si
end

#text(value) ⇒ Object



29
30
31
# File 'lib/saxlsx/shared_string_collection_parser.rb', line 29

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