openxml/openxml-drawingml

View on GitHub
lib/openxml/drawingml/elements/head_end.rb

Summary

Maintainability
A
2 hrs
Test Coverage
module OpenXml
  module DrawingML
    module Elements
      class HeadEnd < OpenXml::Element
        namespace :a
        tag :headEnd

        attribute :length, expects: :valid_end_size, displays_as: :len
        attribute :type, expects: :valid_end_type
        attribute :width, expects: :valid_end_size, displays_as: :w

      private

        def valid_end_size(value)
          ok_values = %i(lg med sm)
          message = "Invalid #{name} (#{value}). Valid values are: #{ok_values.join(", ")}."
          raise ArgumentError, message unless ok_values.include? value
        end

        def valid_end_type(value)
          ok_values = %i(arrow diamond none oval stealth triangle)
          message = "Invalid end type (#{value}). Valid values are: #{ok_values.join(", ")}."
          raise ArgumentError, message unless ok_values.include? value
        end

      end
    end
  end
end