lib/moxml/namespace.rb in moxml-0.1.0 vs lib/moxml/namespace.rb in moxml-0.1.1
- old
+ new
@@ -1,54 +1,29 @@
+# frozen_string_literal: true
+
module Moxml
class Namespace < Node
- def initialize(prefix_or_native = nil, uri = nil)
- case prefix_or_native
- when String
- super(adapter.create_namespace(nil, prefix_or_native, uri))
- else
- super(prefix_or_native)
- end
- end
-
def prefix
- adapter.namespace_prefix(native)
+ adapter.namespace_prefix(@native)
end
- def prefix=(new_prefix)
- adapter.set_namespace_prefix(native, new_prefix)
- self
- end
-
def uri
- adapter.namespace_uri(native)
+ adapter.namespace_uri(@native)
end
- def uri=(new_uri)
- adapter.set_namespace_uri(native, new_uri)
- self
- end
-
- def blank?
- uri.nil? || uri.empty?
- end
-
- def namespace?
- true
- end
-
def ==(other)
- other.is_a?(Namespace) &&
- other.prefix == prefix &&
- other.uri == uri
+ other.is_a?(Namespace) && prefix == other.prefix && uri == other.uri
end
def to_s
- prefix ? "xmlns:#{prefix}='#{uri}'" : "xmlns='#{uri}'"
+ if prefix
+ %(xmlns:#{prefix}="#{uri}")
+ else
+ %(xmlns="#{uri}")
+ end
end
- private
-
- def create_native_node
- adapter.create_namespace(nil, "", "")
+ def namespace?
+ true
end
end
end