class Xlsxrb::Ooxml::Reader::CustomPropertiesListener
SAX2 listener for parsing custom properties (docProps/custom.xml).
Attributes
Public Class Methods
Source
# File lib/xlsxrb/ooxml/reader.rb, line 3030 def initialize @properties = [] @current_name = nil @current_type = nil @text_buffer = +"" end
Public Instance Methods
Source
# File lib/xlsxrb/ooxml/reader.rb, line 3060 def characters(text) @text_buffer << text if @current_type end
# File lib/xlsxrb/ooxml/reader.rb, line 3064 def end_element(_uri, local_name, qname) name = element_name(local_name, qname) case name when "property" @current_name = nil when "lpwstr", "i4", "r8", "bool", "filetime" if @current_name value = case @current_type when :number then @text_buffer.to_i when :float then @text_buffer.to_f when :bool then @text_buffer == "true" else @text_buffer.dup end @properties << { name: @current_name, value: value, type: @current_type } end @current_type = nil end end
# File lib/xlsxrb/ooxml/reader.rb, line 3037 def start_element(_uri, local_name, qname, attributes) name = element_name(local_name, qname) case name when "property" @current_name = attributes["name"] when "lpwstr" @current_type = :string @text_buffer = +"" when "i4" @current_type = :number @text_buffer = +"" when "r8" @current_type = :float @text_buffer = +"" when "bool" @current_type = :bool @text_buffer = +"" when "filetime" @current_type = :date @text_buffer = +"" end end