class Moab::FileInstance
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
-
-
-
@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
(see Serializable#initialize)
Serializer::Serializable::new
# File lib/moab/file_instance.rb, line 22 def initialize(opts = {}) super(opts) end
Public Instance Methods
@api internal (see eql?
)
# File lib/moab/file_instance.rb, line 63 def ==(other) eql?(other) end
# File lib/moab/file_instance.rb, line 38 def datetime Moab::UtcTime.output(@datetime) end
# File lib/moab/file_instance.rb, line 34 def datetime=(event_datetime) @datetime = Moab::UtcTime.input(event_datetime) end
@api internal @param other [FileInstance] The other file instance being compared to this instance @return [Boolean] Returns true if self and other have the same path.
# File lib/moab/file_instance.rb, line 55 def eql?(other) return false unless other.respond_to?(:path) # Cannot equal an incomparable type! path == other.path end
@api internal @return [Fixnum] Compute a hash-code for the path string. Two file instances with the same relative path will have the same hash code (and will compare using eql?). @note The hash and eql? methods override the methods inherited from Object.
These methods ensure that instances of this class can be used as Hash keys. See * {http://www.paulbutcher.com/2007/10/navigating-the-equality-maze/} * {http://techbot.me/2011/05/ruby-basics-equality-operators-ruby/} Also overriden is {#==} so that equality tests in other contexts will also return the expected result.
# File lib/moab/file_instance.rb, line 75 def hash path.hash end
@api internal @param pathname [Pathname] The location of the physical file @param base_directory [Pathname] The full path used as the basis of the relative paths reported @return [FileInstance] Returns a file instance containing a physical file’s’ properties
# File lib/moab/file_instance.rb, line 46 def instance_from_file(pathname, base_directory) @path = pathname.expand_path.relative_path_from(base_directory.expand_path).to_s @datetime = pathname.mtime.iso8601 self end