Class: Moab::FileInstance
- Inherits:
-
Serializable
- Object
- Serializable
- Moab::FileInstance
- Includes:
- HappyMapper
- Defined in:
- lib/moab/file_instance.rb
Overview
Copyright © 2012 by The Board of Trustees of the Leland Stanford Junior University. All rights reserved. See LICENSE for details.
The file path and last modification date properties of a file
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
-
#datetime ⇒ Time
Gsub(/n/,‘ ’).
-
#path ⇒ String
The id is the filename path, relative to the file group’s base directory.
Instance Method Summary collapse
-
#==(other) ⇒ Object
(see #eql?).
-
#eql?(other) ⇒ Boolean
Returns true if self and other have the same path.
-
#hash ⇒ Fixnum
Two file instances with the same relative path will have the same hash code (and will compare using eql?).
-
#initialize(opts = {}) ⇒ FileInstance
constructor
A new instance of FileInstance.
-
#instance_from_file(pathname, base_directory) ⇒ FileInstance
Returns a file instance containing a physical file’s’ properties.
Constructor Details
#initialize(opts = {}) ⇒ FileInstance
Returns a new instance of FileInstance.
24 25 26 |
# File 'lib/moab/file_instance.rb', line 24 def initialize(opts={}) super(opts) end |
Instance Attribute Details
Instance Method Details
#==(other) ⇒ Object
(see #eql?)
64 65 66 |
# File 'lib/moab/file_instance.rb', line 64 def ==(other) eql?(other) end |
#eql?(other) ⇒ Boolean
Returns true if self and other have the same path.
58 59 60 |
# File 'lib/moab/file_instance.rb', line 58 def eql?(other) self.path == other.path end |
#hash ⇒ Fixnum
Two file instances with the same relative path will have the same hash code (and will compare using eql?).
76 77 78 |
# File 'lib/moab/file_instance.rb', line 76 def hash path.hash end |
#instance_from_file(pathname, base_directory) ⇒ FileInstance
Returns a file instance containing a physical file’s’ properties
49 50 51 52 53 |
# File 'lib/moab/file_instance.rb', line 49 def instance_from_file(pathname, base_directory) @path = pathname..relative_path_from(base_directory.).to_s @datetime = pathname.mtime.iso8601 self end |