Class: XMP::Document
- Inherits:
-
Object
- Object
- XMP::Document
- Includes:
- Convenience
- Defined in:
- lib/xmp/document.rb
Instance Attribute Summary collapse
-
#namespaces ⇒ Object
readonly
Returns the value of attribute namespaces.
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(doc = nil) ⇒ Document
constructor
A new instance of Document.
Methods included from Convenience
#[], #include?, #respond_to_missing?, #to_h
Constructor Details
#initialize(doc = nil) ⇒ Document
Returns a new instance of Document.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/xmp/document.rb', line 7 def initialize(doc = nil) if doc @xml = doc.root @namespaces = doc.collect_namespaces.map do |ns, url| @xml.add_namespace_definition ns, url ns[/^(?:xmlns:)?xmlns:(.+)/, 1] end else @xml = nil @namespaces = [] end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class XMP::Convenience
Instance Attribute Details
#namespaces ⇒ Object (readonly)
Returns the value of attribute namespaces.
4 5 6 |
# File 'lib/xmp/document.rb', line 4 def namespaces @namespaces end |
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
5 6 7 |
# File 'lib/xmp/document.rb', line 5 def xml @xml end |
Instance Method Details
#empty? ⇒ Boolean
20 21 22 |
# File 'lib/xmp/document.rb', line 20 def empty? @xml.nil? end |