Sha256: 15471c3e9fd02a169e15f7ae0b92efac97dc9c6fc56343f58352087aae8e2009

Contents?: true

Size: 992 Bytes

Versions: 9

Compression:

Stored size: 992 Bytes

Contents

# frozen_striing_literal: true

module Lutaml
  module Model
    module XmlAdapter
      class XmlNamespace
        # Return name
        #
        # @return [String]
        #
        # @api private
        attr_accessor :uri

        # Return prefix
        #
        # @return [String]
        #
        # @api private
        attr_accessor :prefix

        # Initialize instance
        #
        # @param [String, nil] name
        # @param [String, nil] prefix
        #
        # @api private
        def initialize(uri = nil, prefix = nil)
          @uri = uri
          @prefix = normalize_prefix(prefix)
        end

        def normalize_prefix(prefix)
          normalized_prefix = prefix.to_s.gsub(/xmlns:?/, "")
          return if normalized_prefix.empty?

          normalized_prefix
        end

        def attr_name
          if prefix && !prefix.empty?
            "xmlns:#{prefix}"
          else
            "xmlns"
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
lutaml-model-0.3.10 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.9 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.8 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.7 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.6 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.5 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.4 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.3 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.2 lib/lutaml/model/xml_adapter/xml_namespace.rb