Sha256: 1db20b4a0b163f975436ddc4d1eff9fde9c7fbc7c55a1ec426c52630b3d0c978

Contents?: true

Size: 816 Bytes

Versions: 4

Compression:

Stored size: 816 Bytes

Contents

module OpenXml
  module DrawingML
    module Properties
      class Extent < OpenXml::Properties::ComplexProperty
        namespace :a
        tag :ext

        attribute :cx, expects: :positive_coordinate
        attribute :cy, expects: :positive_coordinate

      private

        def positive_coordinate(value)
          message = "Invalid positive coordinate: should either be an integer (in EMUs) or include a unit"
          raise ArgumentError, message unless positive_integer?(value) || positive_string_with_units?(value)
        end

        def positive_integer?(value)
          value.is_a?(Integer) && value >= 0
        end

        def positive_string_with_units?(value)
          value.is_a?(String) && value =~ OpenXml::DrawingML::ST_PositiveUniversalMeasure
        end

      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
openxml-drawingml-0.3.1 lib/openxml/drawingml/properties/extent.rb
openxml-drawingml-0.3.0 lib/openxml/drawingml/properties/extent.rb
openxml-drawingml-0.2.1 lib/openxml/drawingml/properties/extent.rb
openxml-drawingml-0.2.0 lib/openxml/drawingml/properties/extent.rb