Sha256: eb7e00661ada33b3feeb6ffe96dd7c2edb858225b38461509c3b3689694c198e

Contents?: true

Size: 927 Bytes

Versions: 33

Compression:

Stored size: 927 Bytes

Contents

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

    def id
      self['ID']
    end

    def use
      self['USE']
    end

    def files
      xpath('xmlns:file').map { |node| File.new(node) }
    end

    def flocats
      xpath('xmlns:FLocat').map { |node| FLocat.new(node) }
    end

    def effective_use
      if use
        use
      else
        case parent.name
          when "file"
            File.new(parent).effective_use
          when "fileGrp"
            FileGrp.new(parent).effective_use
        end
      end
    end

    def repo_ids
      flocats.map(&:repo_id)
    end

    def self.build(args)
      node = Nokogiri::XML::Node.new('file', args[:document])
      node['ID'] = args[:id] if args[:id]
      node['USE'] = args[:use] if args[:use]
      node
    end

    def self.find(structure, fileid)
      structure.files[fileid]
    end

  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
ddr-core-1.11.0 lib/ddr/structures/file.rb
ddr-core-1.10.0 lib/ddr/structures/file.rb
ddr-core-1.9.0 lib/ddr/structures/file.rb
ddr-core-1.8.0 lib/ddr/structures/file.rb
ddr-core-1.7.0 lib/ddr/structures/file.rb
ddr-core-1.6.6 lib/ddr/structures/file.rb
ddr-core-1.6.5 lib/ddr/structures/file.rb
ddr-core-1.6.4 lib/ddr/structures/file.rb
ddr-core-1.6.3 lib/ddr/structures/file.rb
ddr-core-1.6.2 lib/ddr/structures/file.rb
ddr-core-1.6.1 lib/ddr/structures/file.rb
ddr-core-1.6.0 lib/ddr/structures/file.rb
ddr-core-1.5.5 lib/ddr/structures/file.rb
ddr-core-1.5.4 lib/ddr/structures/file.rb
ddr-core-1.5.2 lib/ddr/structures/file.rb
ddr-core-1.5.3 lib/ddr/structures/file.rb
ddr-core-1.5.1 lib/ddr/structures/file.rb
ddr-core-1.4.4 lib/ddr/structures/file.rb
ddr-core-1.4.3 lib/ddr/structures/file.rb
ddr-core-1.4.2 lib/ddr/structures/file.rb