Class: Longleaf::PhysicalPathProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/longleaf/candidates/physical_path_provider.rb

Overview

Provides physical paths for logical paths from a mapping

Instance Method Summary collapse

Constructor Details

#initialize(phys_mapping = Hash.new) ⇒ PhysicalPathProvider

Returns a new instance of PhysicalPathProvider.

Parameters:

  • phys_mapping (defaults to: Hash.new)

    hash with logical paths as keys, physical paths as values



5
6
7
# File 'lib/longleaf/candidates/physical_path_provider.rb', line 5

def initialize(phys_mapping = Hash.new)
  @phys_mapping = phys_mapping
end

Instance Method Details

#get_physical_path(logical_path) ⇒ Object

Returns physical path of the file.

Parameters:

  • logical_path (String)

    logical path of file

Returns:

  • physical path of the file



11
12
13
14
15
# File 'lib/longleaf/candidates/physical_path_provider.rb', line 11

def get_physical_path(logical_path)
  # return the logical path itself if no physical path is mapped
  return logical_path unless @phys_mapping.key?(logical_path)
  @phys_mapping[logical_path]
end