Sha256: cee8d0b25aa1f83ed687a4ed9b775083d84485797ceb040d4e68a8664ef0bab2
Contents?: true
Size: 1.59 KB
Versions: 2
Compression:
Stored size: 1.59 KB
Contents
module Longleaf # Record for an individual file and its associated information class FileRecord attr_accessor :metadata_record attr_reader :storage_location attr_reader :path # @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. 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 # @return [String] path for the metadata file for this file def metadata_path @metadata_path = @storage_location.get_metadata_path_for(path) if @metadata_path.nil? @metadata_path end 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 def metadata_present? File.exist?(metadata_path) end def ==(other_obj) return false unless other_obj.is_a?(FileRecord) path == other_obj.path end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
longleaf-1.1.1 | lib/longleaf/models/file_record.rb |
longleaf-1.1.0 | lib/longleaf/models/file_record.rb |