Class: XMP::Namespace
- Inherits:
-
Object
- Object
- XMP::Namespace
- Defined in:
- lib/xmp/namespace.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
available attributes.
Instance Method Summary collapse
-
#initialize(xmp, namespace) ⇒ Namespace
constructor
:nodoc.
- #inspect ⇒ Object
- #method_missing(method, *args) ⇒ Object
- #respond_to?(method) ⇒ Boolean
Constructor Details
#initialize(xmp, namespace) ⇒ Namespace
:nodoc
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/xmp/namespace.rb', line 6 def initialize(xmp, namespace) # :nodoc @xmp = xmp @namespace = namespace.to_s @attributes = [] = xml.xpath("//rdf:Description").map { |d| d.attributes.values. select { |attr| attr.namespace ? attr.namespace.prefix.to_s : nil == @namespace }. map(&:name) }.flatten @attributes.concat standalone_attributes = xml.xpath("//rdf:Description/#{@namespace}:*"). map(&:name) @attributes.concat standalone_attributes end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/xmp/namespace.rb', line 27 def method_missing(method, *args) if has_attribute?(method) (method) || standalone_attribute(method) else super end end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
available attributes
4 5 6 |
# File 'lib/xmp/namespace.rb', line 4 def attributes @attributes end |
Instance Method Details
#inspect ⇒ Object
23 24 25 |
# File 'lib/xmp/namespace.rb', line 23 def inspect "#<XMP::Namespace:#{@namespace}>" end |
#respond_to?(method) ⇒ Boolean
35 36 37 |
# File 'lib/xmp/namespace.rb', line 35 def respond_to?(method) has_attribute?(method) or super end |