Class: Moab::FileManifestation
- Inherits:
-
Serializable
- Object
- Serializable
- Moab::FileManifestation
- Includes:
- HappyMapper
- Defined in:
- lib/moab/file_manifestation.rb
Overview
Copyright © 2012 by The Board of Trustees of the Leland Stanford Junior University. All rights reserved. See LICENSE for details.
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
-
FileInventory = container for recording information about a collection of related files
-
FileGroup [1..*] = subset allow segregation of content and metadata files.
-
FileManifestation [1..*] = snapshot of a file’s filesystem characteristics
-
FileSignature [1] = file fixity information
-
FileInstance [1..*] = filepath and timestamp of any physical file having that signature
-
-
-
Instance Attribute Summary collapse
-
#instances ⇒ Array<FileInstance>
The location(s) of the file manifestation’s file instances.
-
#signature ⇒ FileSignature
The fixity data of the file instance.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
True if FileManifestation objects have same content.
-
#block_count ⇒ Integer
The total disk usage (in 1 kB blocks) of all files that share this manifestation’s signature (estimating du -k result).
-
#byte_count ⇒ Integer
The total size (in bytes) of all files that share this manifestation’s signature.
-
#file_count ⇒ Integer
The total number of FileInstance objects in this manifestation.
-
#initialize(opts = {}) ⇒ FileManifestation
constructor
A new instance of FileManifestation.
-
#paths ⇒ Array<String>
Create an array from all the file paths of the child FileInstance objects.
Constructor Details
#initialize(opts = {}) ⇒ FileManifestation
Returns a new instance of FileManifestation.
27 28 29 30 |
# File 'lib/moab/file_manifestation.rb', line 27 def initialize(opts={}) @instances = Array.new super(opts) end |
Instance Attribute Details
#instances ⇒ Array<FileInstance>
Returns The location(s) of the file manifestation’s file instances.
46 |
# File 'lib/moab/file_manifestation.rb', line 46 has_many :instances, FileInstance, :tag => 'fileInstance' |
#signature ⇒ FileSignature
Returns The fixity data of the file instance.
34 |
# File 'lib/moab/file_manifestation.rb', line 34 element :signature, FileSignature, :tag => 'fileSignature' |
Instance Method Details
#==(other) ⇒ Boolean
Returns True if Moab::FileManifestation objects have same content.
79 80 81 |
# File 'lib/moab/file_manifestation.rb', line 79 def ==(other) (self.signature == other.signature) && (self.instances == other.instances) end |
#block_count ⇒ Integer
Returns The total disk usage (in 1 kB blocks) of all files that share this manifestation’s signature (estimating du -k result).
70 71 72 73 74 |
# File 'lib/moab/file_manifestation.rb', line 70 def block_count block_size=1024 instance_blocks = (signature.size.to_i + block_size - 1)/block_size file_count * instance_blocks end |
#byte_count ⇒ Integer
Returns The total size (in bytes) of all files that share this manifestation’s signature.
63 64 65 |
# File 'lib/moab/file_manifestation.rb', line 63 def byte_count file_count.to_i * signature.size.to_i end |
#file_count ⇒ Integer
Returns The total number of Moab::FileInstance objects in this manifestation. (Number of files that share this manifestation’s signature).
57 58 59 |
# File 'lib/moab/file_manifestation.rb', line 57 def file_count instances.size end |
#paths ⇒ Array<String>
Returns Create an array from all the file paths of the child Moab::FileInstance objects.
50 51 52 |
# File 'lib/moab/file_manifestation.rb', line 50 def paths instances.collect { |i| i.path} end |