Class: Moab::FileInstance
- Inherits:
-
Serializer::Serializable
- Object
- Serializer::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 ⇒ String
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.
Methods inherited from Serializer::Serializable
#array_to_hash, deep_diff, #diff, #key, #key_name, #summary, #to_hash, #to_json, #to_yaml, #variable_names, #variables
Constructor Details
#initialize(opts = {}) ⇒ FileInstance
Returns a new instance of FileInstance.
20 21 22 |
# File 'lib/moab/file_instance.rb', line 20 def initialize(opts = {}) super(opts) end |
Instance Attribute Details
#datetime ⇒ String
Returns gsub(/n/,‘ ’).
30 |
# File 'lib/moab/file_instance.rb', line 30 attribute :datetime, String |
#path ⇒ String
Returns The id is the filename path, relative to the file group’s base directory.
26 |
# File 'lib/moab/file_instance.rb', line 26 attribute :path, String, :key => true |
Instance Method Details
#==(other) ⇒ Object
(see #eql?)
60 61 62 |
# File 'lib/moab/file_instance.rb', line 60 def ==(other) eql?(other) end |
#eql?(other) ⇒ Boolean
Returns true if self and other have the same path.
53 54 55 56 |
# File 'lib/moab/file_instance.rb', line 53 def eql?(other) return false unless other.respond_to?(:path) # Cannot equal an incomparable type! 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?).
72 73 74 |
# File 'lib/moab/file_instance.rb', line 72 def hash path.hash end |
#instance_from_file(pathname, base_directory) ⇒ FileInstance
Returns a file instance containing a physical file’s’ properties
44 45 46 47 48 |
# File 'lib/moab/file_instance.rb', line 44 def instance_from_file(pathname, base_directory) @path = pathname..relative_path_from(base_directory.).to_s @datetime = pathname.mtime.iso8601 self end |