Class: Taurus::XML::Namespace

Inherits:
Object
  • Object
show all
Defined in:
lib/taurus/xml/namespace.rb

Overview

libtaurus's TaurusNamespace is const char* (the URI directly). The Ruby Namespace wrapper holds (element, uri, optional prefix). When the prefix isn't supplied (e.g. via Element#namespace), it can be derived by walking the element's namespace declarations via taurus_element_namespace_decl_*.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element, href, prefix: :derive) ⇒ Namespace

Returns a new instance of Namespace.



11
12
13
14
15
# File 'lib/taurus/xml/namespace.rb', line 11

def initialize(element, href, prefix: :derive)
  @element = element
  @href = href
  @prefix = prefix == :derive ? derive_prefix : prefix
end

Instance Attribute Details

#elementObject (readonly)

Returns the value of attribute element.



9
10
11
# File 'lib/taurus/xml/namespace.rb', line 9

def element
  @element
end

#hrefObject (readonly)

Returns the value of attribute href.



9
10
11
# File 'lib/taurus/xml/namespace.rb', line 9

def href
  @href
end

#prefixObject (readonly)

Returns the value of attribute prefix.



9
10
11
# File 'lib/taurus/xml/namespace.rb', line 9

def prefix
  @prefix
end

Instance Method Details

#==(other) ⇒ Object



21
22
23
24
# File 'lib/taurus/xml/namespace.rb', line 21

def ==(other)
  other.is_a?(Taurus::XML::Namespace) &&
    @href == other.href && @prefix == other.prefix
end

#documentObject



17
18
19
# File 'lib/taurus/xml/namespace.rb', line 17

def document
  @element&.document
end

#inspectObject



26
27
28
# File 'lib/taurus/xml/namespace.rb', line 26

def inspect
  "#<#{self.class.name} prefix=#{@prefix.inspect} href=#{@href.inspect}>"
end