Sha256: 25139cdfb5a0f292a82df53f099e8ce395624c946ce0b3cab2b28e453e66287c

Contents?: true

Size: 968 Bytes

Versions: 33

Compression:

Stored size: 968 Bytes

Contents

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

    def id
      self['ID']
    end

    def loctype
      self['LOCTYPE']
    end

    def otherloctype
      self['OTHERLOCTYPE']
    end

    def use
      self['USE']
    end

    def href
      self['xlink:href']
    end

    def ark?
      loctype == 'ARK'
    end

    def ark
      href if ark?
    end

    def effective_use
      use ? use : File.new(parent).effective_use
    end

    def repo_id
      SolrDocument.find_by_permanent_id(ark).id if ark?
    end

    def self.build(args)
      node = Nokogiri::XML::Node.new('FLocat', args[:document])
      node['ID'] = args[:id] if args[:id]
      node['LOCTYPE'] = args[:loctype] if args[:loctype]
      node['OTHERLOCTYPE'] = args[:otherloctype] if args[:otherloctype]
      node['USE'] = args[:use] if args[:use]
      node['xlink:href'] = args[:href] if args[:href]
      node
    end

  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
ddr-core-1.4.0 lib/ddr/structures/f_locat.rb
ddr-core-1.3.0 lib/ddr/structures/f_locat.rb
ddr-core-1.2.0 lib/ddr/structures/f_locat.rb
ddr-core-1.2.0.rc3 lib/ddr/structures/f_locat.rb
ddr-core-1.2.0.rc2 lib/ddr/structures/f_locat.rb
ddr-core-1.2.0.rc1 lib/ddr/structures/f_locat.rb
ddr-core-1.1.2 lib/ddr/structures/f_locat.rb
ddr-core-1.1.1 lib/ddr/structures/f_locat.rb
ddr-core-1.1.0 lib/ddr/structures/f_locat.rb
ddr-core-1.0.0 lib/ddr/structures/f_locat.rb
ddr-core-0.3.0 lib/ddr/structures/f_locat.rb
ddr-core-0.2.2 lib/ddr/structures/f_locat.rb
ddr-core-0.2.1 lib/ddr/structures/f_locat.rb