Class: Longleaf::FileRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/longleaf/models/file_record.rb

Overview

Record for an individual file and its associated information

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path, storage_location, metadata_record = nil) ⇒ FileRecord

Returns a new instance of FileRecord.

Parameters:

  • file_path (String)

    path to the file

  • storage_location (StorageLocation)

    storage location containing the file

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
# File 'lib/longleaf/models/file_record.rb', line 10

def initialize(file_path, storage_location,  = 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 = 
end

Instance Attribute Details

#metadata_recordObject

Returns the value of attribute metadata_record.



4
5
6
# File 'lib/longleaf/models/file_record.rb', line 4

def 
  @metadata_record
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/longleaf/models/file_record.rb', line 6

def path
  @path
end

#storage_locationObject (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



29
30
31
32
# File 'lib/longleaf/models/file_record.rb', line 29

def ==(other_obj)
  return false unless other_obj.is_a?(FileRecord)
  path == other_obj.path
end

#metadata_pathString

Returns path for the metadata file for this file.

Returns:

  • (String)

    path for the metadata file for this file



20
21
22
23
# File 'lib/longleaf/models/file_record.rb', line 20

def 
  @metadata_path = @storage_location.(path) if @metadata_path.nil?
  @metadata_path
end

#metadata_present?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/longleaf/models/file_record.rb', line 25

def 
  File.exist?()
end