Sha256: 6802f0d4e29cf829ee3676bc2dc3dd596e9b0971961d35fbddee7e5a3406dfc2

Contents?: true

Size: 896 Bytes

Versions: 3

Compression:

Stored size: 896 Bytes

Contents

# frozen_string_literal: true

module Goldendocx
  module Images
    module Properties
      class ShapeProperty
        include Goldendocx::Element

        # 1 : 0.618
        DEFAULT_SHAPE_WIDTH = Goldendocx::Units::EMU_PER_CENTIMETER * 15
        DEFAULT_SHAPE_HEIGHT = Goldendocx::Units::EMU_PER_CENTIMETER * 9.27

        attr_accessor :width, :height

        namespace :v
        tag :shape

        attribute :style, method: :formatted_style

        embeds_one :image_data, class_name: 'Goldendocx::Images::Properties::ImageDataProperty', auto_build: true

        def formatted_style
          height = ((self.height || DEFAULT_SHAPE_HEIGHT) / Goldendocx::Units::EMU_PER_CENTIMETER).round(2)
          width = ((self.width || DEFAULT_SHAPE_WIDTH) / Goldendocx::Units::EMU_PER_CENTIMETER).round(2)
          "height:#{height}cm;width:#{width}cm"
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
goldendocx-0.3.0 lib/goldendocx/images/properties/shape_property.rb
goldendocx-0.2.3 lib/goldendocx/images/properties/shape_property.rb
goldendocx-0.2.2 lib/goldendocx/images/properties/shape_property.rb