class Moab::FileManifestation

A container for a file signature and all the physical file instances that have that signature This element has one child {FileSignature} element, and one or more {FileInstance} elements Regarding the class name, see

Data Model

@note Copyright © 2012 by The Board of Trustees of the Leland Stanford Junior University.

All rights reserved.  See {file:LICENSE.rdoc} for details.

Public Class Methods

new(opts = {}) click to toggle source

(see Serializable#initialize)

Calls superclass method Serializer::Serializable::new
# File lib/moab/file_manifestation.rb, line 26
def initialize(opts = {})
  @instances = []
  super(opts)
end

Public Instance Methods

==(other) click to toggle source

@api internal @param other [FileManifestation] The {FileManifestation} object to compare with self @return [Boolean] True if {FileManifestation} objects have same content

# File lib/moab/file_manifestation.rb, line 78
def ==(other)
  return false unless other.respond_to?(:signature) && other.respond_to?(:instances) # Cannot equal an incomparable type!

  (signature == other.signature) && (instances == other.instances)
end
block_count() click to toggle source

@api internal @return [Integer] The total disk usage (in 1 kB blocks) of all files that share this manifestation’s signature

(estimating du -k result)
# File lib/moab/file_manifestation.rb, line 69
def block_count
  block_size = 1024
  instance_blocks = (signature.size.to_i + block_size - 1) / block_size
  file_count * instance_blocks
end
byte_count() click to toggle source

@api internal @return [Integer] The total size (in bytes) of all files that share this manifestation’s signature

# File lib/moab/file_manifestation.rb, line 62
def byte_count
  file_count.to_i * signature.size.to_i
end
file_count() click to toggle source

@api internal @return [Integer] The total number of {FileInstance} objects in this manifestation.

(Number of files that share this manifestation's signature)
# File lib/moab/file_manifestation.rb, line 56
def file_count
  instances.size
end
paths() click to toggle source

@api internal @return [Array<String>] Create an array from all the file paths of the child {FileInstance} objects

# File lib/moab/file_manifestation.rb, line 49
def paths
  instances.collect(&:path)
end
signature() click to toggle source
# File lib/moab/file_manifestation.rb, line 35
def signature
  @signature.is_a?(Array) ? @signature[0] : @signature
end
signature=(signature) click to toggle source
# File lib/moab/file_manifestation.rb, line 39
def signature=(signature)
  @signature = signature.is_a?(Array) ? signature[0] : signature
end