Method: Longleaf::FilesystemStorageLocation#relativize

Defined in:
lib/longleaf/models/filesystem_storage_location.rb

#relativize(file_path) ⇒ Object

Get the file path relative to this location

Parameters:

  • file_path (String)

    file path

Returns:

  • the file path relative to this location

Raises:

  • (ArgumentError)

    if the file path is not contained by this location



44
45
46
47
48
49
50
# File 'lib/longleaf/models/filesystem_storage_location.rb', line 44

def relativize(file_path)
  return file_path if Pathname.new(file_path).relative?

  raise ArgumentError.new("Metadata path must be contained by this location") if !file_path.start_with?(@path)

  file_path.sub(@path, "")
end