Class: Ddr::Structures::Agent
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Ddr::Structures::Agent
- Defined in:
- lib/ddr/structures/agent.rb
Overview
Wraps a Nokogiri (XML) 'agent' node
Constant Summary collapse
- ROLE_CREATOR =
'CREATOR'.freeze
- NAME_REPOSITORY_DEFAULT =
'REPOSITORY DEFAULT'.freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.build(args) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ddr/structures/agent.rb', line 35 def self.build(args) node = Nokogiri::XML::Node.new('agent', args[:document]) node['ID'] = args[:id] if args[:id] node['ROLE'] = args[:role] if args[:role] node['OTHERROLE'] = args[:otherrole] if args[:otherrole] node['TYPE'] = args[:type] if args[:type] node['OTHERTYPE'] = args[:othertype] if args[:othertype] name_node = Nokogiri::XML::Node.new('name', args[:document]) name_node.content = args[:name] node.add_child(name_node) node end |
Instance Method Details
#id ⇒ Object
11 12 13 |
# File 'lib/ddr/structures/agent.rb', line 11 def id self['ID'] end |
#name ⇒ Object
31 32 33 |
# File 'lib/ddr/structures/agent.rb', line 31 def name xpath('xmlns:name').first.content end |
#otherrole ⇒ Object
19 20 21 |
# File 'lib/ddr/structures/agent.rb', line 19 def otherrole self['OTHERROLE'] end |
#othertype ⇒ Object
27 28 29 |
# File 'lib/ddr/structures/agent.rb', line 27 def othertype self['OTHERTYPE'] end |
#role ⇒ Object
15 16 17 |
# File 'lib/ddr/structures/agent.rb', line 15 def role self['ROLE'] end |
#type ⇒ Object
23 24 25 |
# File 'lib/ddr/structures/agent.rb', line 23 def type self['TYPE'] end |