class ChupaText::Decomposers::OfficeOpenXML::AttributesListener

Constants

CORE_PROPERTIES_URI
DUBLIN_CORE_TERMS_URI
DUBLIN_CORE_URI
EXTENDED_PROPERTIES_URI

Public Class Methods

new(attributes) click to toggle source
# File lib/chupa-text/decomposers/office-open-xml.rb, line 125
def initialize(attributes)
  @attributes = attributes
  @name = nil
  @type = nil
end

Public Instance Methods

cdata(content) click to toggle source
# File lib/chupa-text/decomposers/office-open-xml.rb, line 166
def cdata(content)
  set_attribute(content)
end
characters(text) click to toggle source
# File lib/chupa-text/decomposers/office-open-xml.rb, line 162
def characters(text)
  set_attribute(text)
end
end_element(uri, local_name, qname) click to toggle source
# File lib/chupa-text/decomposers/office-open-xml.rb, line 157
def end_element(uri, local_name, qname)
  @name = nil
  @type = nil
end
set_attribute(value) click to toggle source
# File lib/chupa-text/decomposers/office-open-xml.rb, line 170
def set_attribute(value)
  return if @name.nil?

  value = CGI.unescapeHTML(value)
  case @type
  when :w3cdtf
    value = Time.xmlschema(value)
  end
  @attributes[@name] = value
end
start_element(uri, local_name, qname, attributes) click to toggle source
# File lib/chupa-text/decomposers/office-open-xml.rb, line 131
def start_element(uri, local_name, qname, attributes)
  case uri
  when CORE_PROPERTIES_URI
    case local_name
    when "keywords"
      @name = local_name
    end
  when EXTENDED_PROPERTIES_URI
    case local_name
    when "Application"
      @name = local_name.downcase
    end
  when DUBLIN_CORE_URI
    case local_name
    when "description", "title", "subject"
      @name = local_name
    end
  when DUBLIN_CORE_TERMS_URI
    case local_name
    when "created", "modified"
      @name = "#{local_name}_time"
      @type = :w3cdtf
    end
  end
end