Sha256: 77f27c3cbec9f4f6a6e357b9d81e5a9eaf35e4a2319f0458f32f81d2c2df1437

Contents?: true

Size: 990 Bytes

Versions: 18

Compression:

Stored size: 990 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 Utils.present?(prefix)
            "xmlns:#{prefix}"
          else
            "xmlns"
          end
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
lutaml-model-0.3.28 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.27 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.26 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.25 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.24 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.23 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.22 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.21 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.20 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.19 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.18 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.17 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.16 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.15 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.14 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.13 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.12 lib/lutaml/model/xml_adapter/xml_namespace.rb
lutaml-model-0.3.11 lib/lutaml/model/xml_adapter/xml_namespace.rb