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.11.0 lib/ddr/structures/f_locat.rb
ddr-core-1.10.0 lib/ddr/structures/f_locat.rb
ddr-core-1.9.0 lib/ddr/structures/f_locat.rb
ddr-core-1.8.0 lib/ddr/structures/f_locat.rb
ddr-core-1.7.0 lib/ddr/structures/f_locat.rb
ddr-core-1.6.6 lib/ddr/structures/f_locat.rb
ddr-core-1.6.5 lib/ddr/structures/f_locat.rb
ddr-core-1.6.4 lib/ddr/structures/f_locat.rb
ddr-core-1.6.3 lib/ddr/structures/f_locat.rb
ddr-core-1.6.2 lib/ddr/structures/f_locat.rb
ddr-core-1.6.1 lib/ddr/structures/f_locat.rb
ddr-core-1.6.0 lib/ddr/structures/f_locat.rb
ddr-core-1.5.5 lib/ddr/structures/f_locat.rb
ddr-core-1.5.4 lib/ddr/structures/f_locat.rb
ddr-core-1.5.2 lib/ddr/structures/f_locat.rb
ddr-core-1.5.3 lib/ddr/structures/f_locat.rb
ddr-core-1.5.1 lib/ddr/structures/f_locat.rb
ddr-core-1.4.4 lib/ddr/structures/f_locat.rb
ddr-core-1.4.3 lib/ddr/structures/f_locat.rb
ddr-core-1.4.2 lib/ddr/structures/f_locat.rb