Class: XML::MappingExtensions::Namespace
- Inherits:
-
Object
- Object
- XML::MappingExtensions::Namespace
- Defined in:
- lib/xml/mapping_extensions/namespace.rb
Overview
Encapsulates an XML namespace with a URI, schema location, and optional prefix.
Instance Attribute Summary collapse
-
#prefix ⇒ String?
readonly
The namespace prefix.
-
#schema_location ⇒ URI, ...
readonly
The schema location URI.
-
#uri ⇒ String
readonly
The string form of the namespace URI.
Instance Method Summary collapse
- #==(other) (also: #eql?)
- #hash
-
#initialize(uri:, prefix: nil, schema_location: nil) ⇒ Namespace
constructor
Creates a new Namespace.
- #to_s
Constructor Details
#initialize(uri:, prefix: nil, schema_location: nil) ⇒ Namespace
Creates a new XML::MappingExtensions::Namespace
24 25 26 27 28 29 |
# File 'lib/xml/mapping_extensions/namespace.rb', line 24 def initialize(uri:, prefix: nil, schema_location: nil) raise URI::InvalidURIError, 'uri cannot be nil' unless uri @uri = MappingExtensions.to_uri_str(uri) @prefix = prefix @schema_location = MappingExtensions.to_uri_str(schema_location) end |
Instance Attribute Details
#prefix ⇒ String? (readonly)
Returns the namespace prefix.
13 14 15 |
# File 'lib/xml/mapping_extensions/namespace.rb', line 13 def prefix @prefix end |
#schema_location ⇒ URI, ... (readonly)
Returns the schema location URI.
16 17 18 |
# File 'lib/xml/mapping_extensions/namespace.rb', line 16 def schema_location @schema_location end |
#uri ⇒ String (readonly)
Returns the string form of the namespace URI.
10 11 12 |
# File 'lib/xml/mapping_extensions/namespace.rb', line 10 def uri @uri end |
Instance Method Details
#==(other) Also known as: eql?
35 36 37 |
# File 'lib/xml/mapping_extensions/namespace.rb', line 35 def ==(other) other.class == self.class && other.state == state end |
#hash
41 42 43 |
# File 'lib/xml/mapping_extensions/namespace.rb', line 41 def hash state.hash end |
#to_s
31 32 33 |
# File 'lib/xml/mapping_extensions/namespace.rb', line 31 def to_s "Namespace(uri: #{uri}, prefix: #{prefix || 'nil'}, schema_location: #{schema_location || 'nil'}" end |