Sha256: 8cff950770728e1f48cdb66b401a574cd6ed52e68cf0647374a5489e6f837081

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

module Goldendocx
  module Images
    class Picture
      include Goldendocx::Element

      namespace :pic
      tag :pic

      embeds_one :non_visual_picture, class_name: 'Goldendocx::Images::Properties::NonVisualPictureProperty', auto_build: true
      embeds_one :drawing, class_name: 'Goldendocx::Images::Properties::DrawingProperty', auto_build: true
      embeds_one :picture_fill, class_name: 'Goldendocx::Images::Properties::PictureFillProperty', auto_build: true
      embeds_one :picture_shape, class_name: 'Goldendocx::Images::Properties::PictureShapeProperty', auto_build: true

      def initialize(**attributes)
        attributes.each do |name, value|
          send("#{name}=", value) if respond_to?("#{name}=")
        end
      end

      def width=(width)
        picture_shape.transform.extents.width = width if width
      end

      def height=(height)
        picture_shape.transform.extents.height = height if height
      end

      def relationship_id=(relationship_id)
        return unless relationship_id

        non_visual_picture.non_visual_drawing.assign_attributes(
          relationship_id:,
          name: "#{relationship_id}.png"
        )
        picture_fill.blip.relationship_id = relationship_id
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
goldendocx-0.3.0 lib/goldendocx/images/picture.rb