Sha256: 8212f5f71608b1732f74ed9624bdb1734325c2d3fb61109dc3b025af210761b3

Contents?: true

Size: 652 Bytes

Versions: 8

Compression:

Stored size: 652 Bytes

Contents

require 'roo/excelx/extractor'

module Roo
  class Excelx
    class Images < Excelx::Extractor

      # Returns: Hash { id1: extracted_file_name1 },
      # Example: { "rId1"=>"roo_media_image1.png",
      #            "rId2"=>"roo_media_image2.png",
      #            "rId3"=>"roo_media_image3.png" }
      def list
        @images ||= extract_images_names
      end

      private

      def extract_images_names
        return {} unless doc_exists?

        doc.xpath('/Relationships/Relationship').each_with_object({}) do |rel, hash|
          hash[rel['Id']] = "roo" + rel['Target'].gsub(/\.\.\/|\//, '_')
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
roo-2.10.1 lib/roo/excelx/images.rb
roo-2.10.0 lib/roo/excelx/images.rb
roo-2.9.0 lib/roo/excelx/images.rb
ruh-roo-3.0.1 lib/roo/excelx/images.rb
roo-2.8.3 lib/roo/excelx/images.rb
roo-2.8.2 lib/roo/excelx/images.rb
roo-2.8.1 lib/roo/excelx/images.rb
roo-2.8.0 lib/roo/excelx/images.rb