Class: Ddr::Structures::Mptr
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Ddr::Structures::Mptr
- Defined in:
- lib/ddr/structures/mptr.rb
Overview
Wraps a Nokogiri (XML) ‘mptr’ node
Class Method Summary collapse
Instance Method Summary collapse
- #ark ⇒ Object
- #ark? ⇒ Boolean
- #dereferenced_hash ⇒ Object
- #href ⇒ Object
- #id ⇒ Object
- #loctype ⇒ Object
- #otherloctype ⇒ Object
- #repo_id ⇒ Object
- #urn? ⇒ Boolean
Class Method Details
.build(args) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/ddr/structures/mptr.rb', line 47 def self.build(args) node = Nokogiri::XML::Node.new('mptr', args[:document]) node['ID'] = args[:id] if args[:id] node['LOCTYPE'] = args[:loctype] if args[:loctype] node['OTHERLOCTYPE'] = args[:otherloctype] if args[:otherloctype] node['xlink:href'] = args[:href] if args[:href] node end |
Instance Method Details
#ark ⇒ Object
31 32 33 |
# File 'lib/ddr/structures/mptr.rb', line 31 def ark href if ark? end |
#ark? ⇒ Boolean
23 24 25 |
# File 'lib/ddr/structures/mptr.rb', line 23 def ark? loctype == 'ARK' end |
#dereferenced_hash ⇒ Object
43 44 45 |
# File 'lib/ddr/structures/mptr.rb', line 43 def dereferenced_hash { id: id, repo_id: repo_id }.compact end |
#href ⇒ Object
19 20 21 |
# File 'lib/ddr/structures/mptr.rb', line 19 def href self['xlink:href'] end |
#id ⇒ Object
7 8 9 |
# File 'lib/ddr/structures/mptr.rb', line 7 def id self['ID'] end |
#loctype ⇒ Object
11 12 13 |
# File 'lib/ddr/structures/mptr.rb', line 11 def loctype self['LOCTYPE'] end |
#otherloctype ⇒ Object
15 16 17 |
# File 'lib/ddr/structures/mptr.rb', line 15 def otherloctype self['OTHERLOCTYPE'] end |
#repo_id ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/ddr/structures/mptr.rb', line 35 def repo_id if ark? SolrDocument.find_by_permanent_id(ark).id elsif urn? href.sub(/^urn:uuid:/, '') end end |
#urn? ⇒ Boolean
27 28 29 |
# File 'lib/ddr/structures/mptr.rb', line 27 def urn? loctype == 'URN' end |