Class: Xommelier::Xml::Namespace
- Inherits:
-
Object
- Object
- Xommelier::Xml::Namespace
- Defined in:
- lib/xommelier/xml/namespace.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
-
#options ⇒ Object
Returns the value of attribute options.
-
#uri ⇒ Object
(also: #to_s, #href)
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #as ⇒ Object
- #attribute_name ⇒ Object
- #default? ⇒ Boolean
-
#initialize(uri, options = {}, &block) ⇒ Namespace
constructor
A new instance of Namespace.
- #inspect ⇒ Object
- #module ⇒ Object
- #ns ⇒ Object
- #schema ⇒ Object
- #scoped(&block) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(uri, options = {}, &block) ⇒ Namespace
Returns a new instance of Namespace.
19 20 21 22 23 24 25 26 |
# File 'lib/xommelier/xml/namespace.rb', line 19 def initialize(uri, = {}, &block) @uri = uri @options = {} @as = .delete(:as) self. = scoped(&block) if block_given? end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
15 16 17 |
# File 'lib/xommelier/xml/namespace.rb', line 15 def attributes @attributes end |
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
15 16 17 |
# File 'lib/xommelier/xml/namespace.rb', line 15 def elements @elements end |
#options ⇒ Object
Returns the value of attribute options.
15 16 17 |
# File 'lib/xommelier/xml/namespace.rb', line 15 def @options end |
#uri ⇒ Object (readonly) Also known as: to_s, href
Returns the value of attribute uri.
15 16 17 |
# File 'lib/xommelier/xml/namespace.rb', line 15 def uri @uri end |
Instance Method Details
#as ⇒ Object
28 29 30 |
# File 'lib/xommelier/xml/namespace.rb', line 28 def as @as unless default? end |
#attribute_name ⇒ Object
66 67 68 |
# File 'lib/xommelier/xml/namespace.rb', line 66 def attribute_name default? ? 'xmlns' : "xmlns:#{as}" end |
#default? ⇒ Boolean
58 59 60 |
# File 'lib/xommelier/xml/namespace.rb', line 58 def default? uri.to_s == DEFAULT_NS end |
#inspect ⇒ Object
70 71 72 |
# File 'lib/xommelier/xml/namespace.rb', line 70 def inspect %(#{attribute_name}="#{uri}") end |
#module ⇒ Object
46 47 48 |
# File 'lib/xommelier/xml/namespace.rb', line 46 def module [:module] end |
#ns ⇒ Object
32 33 34 |
# File 'lib/xommelier/xml/namespace.rb', line 32 def ns Xommelier::Xml::Namespace.registry end |
#schema ⇒ Object
50 51 52 |
# File 'lib/xommelier/xml/namespace.rb', line 50 def schema self.module.schema end |
#scoped(&block) ⇒ Object
54 55 56 |
# File 'lib/xommelier/xml/namespace.rb', line 54 def scoped(&block) instance_exec(&block) end |
#to_hash ⇒ Object
62 63 64 |
# File 'lib/xommelier/xml/namespace.rb', line 62 def to_hash { as.to_s => uri.to_s } end |