Class: XlsxKit::Workbook::SharedStringsHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/xlsxkit/workbook.rb

Overview


Shared Strings SAX Handler

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ SharedStringsHandler

Returns a new instance of SharedStringsHandler.



286
287
288
289
290
291
# File 'lib/xlsxkit/workbook.rb', line 286

def initialize
  @strings = []
  @in_si = false
  @in_t  = false
  @chars = nil
end

Instance Attribute Details

#strings ⇒ Object (readonly)

Returns the value of attribute strings.



284
285
286
# File 'lib/xlsxkit/workbook.rb', line 284

def strings
  @strings
end

Instance Method Details

#characters(text) ⇒ Object



300
301
302
# File 'lib/xlsxkit/workbook.rb', line 300

def characters(text)
  @chars << text if @in_si && @in_t
end

#end_element(name) ⇒ Object



304
305
306
307
308
309
310
311
312
313
# File 'lib/xlsxkit/workbook.rb', line 304

def end_element(name)
  case name
  when 'si'
    @strings << (@chars || '')
    @in_si = false
    @chars = nil
  when 't'
    @in_t = false
  end
end

#start_element(name, attrs) ⇒ Object



293
294
295
296
297
298
# File 'lib/xlsxkit/workbook.rb', line 293

def start_element(name, attrs)
  case name
  when 'si' then @in_si = true; @chars = +''
  when 't'  then @in_t = true
  end
end