Sha256: 636e7be31d6fec6968694b545aa2734585092c21a43de86d96d70d059f2d76e9

Contents?: true

Size: 1002 Bytes

Versions: 43

Compression:

Stored size: 1002 Bytes

Contents

module Ddr::Structures
  #
  # Wraps a Nokogiri (XML) 'agent' node
  #
  class Agent < SimpleDelegator

    ROLE_CREATOR = 'CREATOR'.freeze

    NAME_REPOSITORY_DEFAULT = 'REPOSITORY DEFAULT'.freeze

    def id
      self['ID']
    end

    def role
      self['ROLE']
    end

    def otherrole
      self['OTHERROLE']
    end

    def type
      self['TYPE']
    end

    def othertype
      self['OTHERTYPE']
    end

    def name
      xpath('xmlns:name').first.content
    end

    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

  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
ddr-core-1.17.0 lib/ddr/structures/agent.rb
ddr-core-1.16.0 lib/ddr/structures/agent.rb
ddr-core-1.15.0 lib/ddr/structures/agent.rb
ddr-core-1.14.0 lib/ddr/structures/agent.rb
ddr-core-1.13.2 lib/ddr/structures/agent.rb
ddr-core-1.13.1 lib/ddr/structures/agent.rb
ddr-core-1.13.0 lib/ddr/structures/agent.rb
ddr-core-1.12.2 lib/ddr/structures/agent.rb
ddr-core-1.12.1 lib/ddr/structures/agent.rb
ddr-core-1.12.0 lib/ddr/structures/agent.rb
ddr-core-1.11.0 lib/ddr/structures/agent.rb
ddr-core-1.10.0 lib/ddr/structures/agent.rb
ddr-core-1.9.0 lib/ddr/structures/agent.rb
ddr-core-1.8.0 lib/ddr/structures/agent.rb
ddr-core-1.7.0 lib/ddr/structures/agent.rb
ddr-core-1.6.6 lib/ddr/structures/agent.rb
ddr-core-1.6.5 lib/ddr/structures/agent.rb
ddr-core-1.6.4 lib/ddr/structures/agent.rb
ddr-core-1.6.3 lib/ddr/structures/agent.rb
ddr-core-1.6.2 lib/ddr/structures/agent.rb