Class: Longleaf::FileRecord
- Inherits:
-
Object
- Object
- Longleaf::FileRecord
- Defined in:
- lib/longleaf/models/file_record.rb
Overview
Record for an individual file and its associated information
Instance Attribute Summary collapse
-
#metadata_record ⇒ Object
Returns the value of attribute metadata_record.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#storage_location ⇒ Object
readonly
Returns the value of attribute storage_location.
Instance Method Summary collapse
- #==(other_obj) ⇒ Object
-
#initialize(file_path, storage_location, metadata_record = nil, physical_path = nil) ⇒ FileRecord
constructor
A new instance of FileRecord.
-
#metadata_path ⇒ String
Path for the metadata file for this file.
- #metadata_present? ⇒ Boolean
- #physical_path ⇒ Object
Constructor Details
#initialize(file_path, storage_location, metadata_record = nil, physical_path = nil) ⇒ FileRecord
Returns a new instance of FileRecord.
12 13 14 15 16 17 18 19 20 |
# File 'lib/longleaf/models/file_record.rb', line 12 def initialize(file_path, storage_location, = 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 = @physical_path = physical_path end |
Instance Attribute Details
#metadata_record ⇒ Object
Returns the value of attribute metadata_record.
4 5 6 |
# File 'lib/longleaf/models/file_record.rb', line 4 def @metadata_record end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/longleaf/models/file_record.rb', line 6 def path @path end |
#storage_location ⇒ Object (readonly)
Returns the value of attribute storage_location.
5 6 7 |
# File 'lib/longleaf/models/file_record.rb', line 5 def storage_location @storage_location end |
Instance Method Details
#==(other_obj) ⇒ Object
43 44 45 46 |
# 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 ⇒ String
Returns path for the metadata file for this file.
23 24 25 26 |
# File 'lib/longleaf/models/file_record.rb', line 23 def @metadata_path = @storage_location.(path) if @metadata_path.nil? @metadata_path end |
#metadata_present? ⇒ Boolean
39 40 41 |
# File 'lib/longleaf/models/file_record.rb', line 39 def File.exist?() end |
#physical_path ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# 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 |