Sha256: 2a316a17114e940372d6c969a39fa443acea5f3224e1c13d31c4eee82d8da3c1

Contents?: true

Size: 720 Bytes

Versions: 4

Compression:

Stored size: 720 Bytes

Contents

module OpenXml
  module DrawingML
    module Properties
      class Offset < OpenXml::Properties::ComplexProperty
        namespace :a
        tag :off

        attribute :x, expects: :coordinate
        attribute :y, expects: :coordinate

      private

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

        def universal_measure?(value)
          value.is_a?(String) && value =~ OpenXml::DrawingML::ST_UniversalMeasure
        end

        def integer?(value)
          value.is_a?(Integer)
        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/offset.rb
openxml-drawingml-0.3.0 lib/openxml/drawingml/properties/offset.rb
openxml-drawingml-0.2.1 lib/openxml/drawingml/properties/offset.rb
openxml-drawingml-0.2.0 lib/openxml/drawingml/properties/offset.rb