Class: XMP::Namespace
- Inherits:
-
Object
- Object
- XMP::Namespace
- Includes:
- Convenience
- Defined in:
- lib/xmp/namespace.rb
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#embedded_attributes ⇒ Object
readonly
Returns the value of attribute embedded_attributes.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#standalone_attributes ⇒ Object
readonly
Returns the value of attribute standalone_attributes.
Instance Method Summary collapse
- #attributes ⇒ Object
-
#initialize(document, namespace) ⇒ Namespace
constructor
A new instance of Namespace.
Methods included from Convenience
#[], #include?, #respond_to_missing?, #to_h
Constructor Details
#initialize(document, namespace) ⇒ Namespace
Returns a new instance of Namespace.
5 6 7 8 9 10 11 |
# File 'lib/xmp/namespace.rb', line 5 def initialize(document, namespace) @document, @namespace = document, namespace @standalone_attributes = xml.xpath("//rdf:Description/#{namespace}:*").map(&:name) @embedded_attributes = xml.xpath('//rdf:Description').flat_map do |description| description.attributes.values.select { |attr| attr.namespace.prefix.to_s == namespace }.map(&:name) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class XMP::Convenience
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
3 4 5 |
# File 'lib/xmp/namespace.rb', line 3 def document @document end |
#embedded_attributes ⇒ Object (readonly)
Returns the value of attribute embedded_attributes.
3 4 5 |
# File 'lib/xmp/namespace.rb', line 3 def @embedded_attributes end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
3 4 5 |
# File 'lib/xmp/namespace.rb', line 3 def namespace @namespace end |
#standalone_attributes ⇒ Object (readonly)
Returns the value of attribute standalone_attributes.
3 4 5 |
# File 'lib/xmp/namespace.rb', line 3 def standalone_attributes @standalone_attributes end |
Instance Method Details
#attributes ⇒ Object
13 14 15 |
# File 'lib/xmp/namespace.rb', line 13 def attributes @attributes ||= (standalone_attributes + ).uniq end |