From c068cd0f3734b8fd34d99a129afa9ce180092d61 Mon Sep 17 00:00:00 2001 From: Sebastiano Date: Sun, 19 Feb 2023 13:43:18 +0100 Subject: refactored code on Pic class --- lib/axlsx/drawing/pic.rb | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/axlsx/drawing/pic.rb b/lib/axlsx/drawing/pic.rb index 4e269721..dda1763c 100644 --- a/lib/axlsx/drawing/pic.rb +++ b/lib/axlsx/drawing/pic.rb @@ -95,10 +95,14 @@ module Axlsx def descr=(v) Axlsx::validate_string(v); @descr = v; end # @see remote - def remote=(v) @remote = v; end + def remote=(v) Axlsx::validate_boolean(v); @remote = v; end def remote? - remote == true; + if remote == 1 || remote.to_s == 'true' + true + else + false + end end # The file name of image_src without any path information @@ -196,11 +200,7 @@ module Axlsx picture_locking.to_xml_string(str) str << '' str << '' - if remote? - str << ('') - else - str << ('') - end + str << relationship_xml_portion if opacity str << "" end @@ -212,6 +212,15 @@ module Axlsx private + # Return correct xml relationship string portion + def relationship_xml_portion + if remote? + ('') + else + ('') + end + end + # Changes the anchor to a one cell anchor. def use_one_cell_anchor return if @anchor.is_a?(OneCellAnchor) -- cgit v1.2.3