aboutsummaryrefslogtreecommitdiffstats
path: root/lib/roo/excelx/images.rb
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@ubuntu.com>2019-01-14 01:40:56 -0500
committerLibravatarUnit 193 <unit193@ubuntu.com>2019-01-14 01:40:56 -0500
commitdddfa903d2b856146f05ffb4415c31d6127bb5bf (patch)
treee38c2aca92b54f06ccd0185f48dc47e3e1b3d77e /lib/roo/excelx/images.rb
parent8280a21a23d44aa90177e2bc041d0b8dc8556f4b (diff)
New upstream version 2.8.0upstream/2.8.0
Diffstat (limited to 'lib/roo/excelx/images.rb')
-rw-r--r--lib/roo/excelx/images.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/roo/excelx/images.rb b/lib/roo/excelx/images.rb
new file mode 100644
index 0000000..cf0221f
--- /dev/null
+++ b/lib/roo/excelx/images.rb
@@ -0,0 +1,26 @@
+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