class Longleaf::FileRecord
Record for an individual file and its associated information
Attributes
metadata_record[RW]
path[R]
storage_location[R]
Public Class Methods
new(file_path, storage_location, metadata_record = nil, physical_path = nil)
click to toggle source
@param file_path [String] path to the file @param storage_location
[StorageLocation] storage location containing the file @param metadata_record
[MetadataRecord] metadata record for this file object. Optional. @param physical_path
[String] physical path where the file is located. Defaults to the file_path.
# File lib/longleaf/models/file_record.rb, line 12 def initialize(file_path, storage_location, metadata_record = nil, physical_path = nil) raise ArgumentError.new("FileRecord requires a path") if file_path.nil? raise ArgumentError.new("FileRecord requires a storage_location") if storage_location.nil? @path = file_path @storage_location = storage_location @metadata_record = metadata_record @physical_path = physical_path end
Public Instance Methods
==(other_obj)
click to toggle source
# File lib/longleaf/models/file_record.rb, line 43 def ==(other_obj) return false unless other_obj.is_a?(FileRecord) path == other_obj.path end
metadata_path()
click to toggle source
@return [String] path for the metadata file for this file
# File lib/longleaf/models/file_record.rb, line 23 def metadata_path @metadata_path = @storage_location.get_metadata_path_for(path) if @metadata_path.nil? @metadata_path end
metadata_present?()
click to toggle source
# File lib/longleaf/models/file_record.rb, line 39 def metadata_present? File.exist?(metadata_path) end
physical_path()
click to toggle source
# File lib/longleaf/models/file_record.rb, line 28 def physical_path if @physical_path.nil? if @metadata_record.nil? || @metadata_record.physical_path.nil? @physical_path = @path else @physical_path = @metadata_record.physical_path end end @physical_path end