Sha256: 08fc6f400200f403561911dc5df2a2fa631774134fe3c08a689f077eae70d9c0
Contents?: true
Size: 1.06 KB
Versions: 15
Compression:
Stored size: 1.06 KB
Contents
require 'psd/resources/base' class PSD class Resource module Section class XMPMetadata < Base resource_id 1060 name :xmp_metadata attr_reader :xml, :data alias_method :to_hash, :data def parse @xml = @file.read(@resource.size) @data = {} @xmp = XMP.new(xml) @xmp.namespaces.each do |a| parse_tree(a.to_sym) end rescue PSD.logger.error "Unable to parse XMP Metadata" ensure @resource.data = self end private def parse_tree(attr_name) @data[attr_name] = {} @xmp.send(attr_name).attributes.each do |a| begin @data[attr_name][a.to_sym] = @xmp.send(attr_name).send(a)[0] rescue @data[attr_name][a.to_sym] = parse_text_node(@xmp.send(attr_name), "//#{attr_name}:#{a}") end end end def parse_text_node(node, path) node.send(:xml).xpath(path).first.text end end end end end
Version data entries
15 entries across 15 versions & 1 rubygems