Class: PathUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/second_curtain/path_utils.rb

Class Method Summary collapse

Class Method Details

.pathWithComponents(components) ⇒ Object

Returns a path composed of components, without leading and trailing slashes



4
5
6
7
8
9
10
11
12
# File 'lib/second_curtain/path_utils.rb', line 4

def self.pathWithComponents(components)
  path = ""

  for component in components do
    path = self.sanitizePathComponent(path + "/" + self.sanitizePathComponent(component))
  end

  return path
end

.sanitizePathComponent(component) ⇒ Object

Takes a path component and strips leading and trailing slashes



17
18
19
20
# File 'lib/second_curtain/path_utils.rb', line 17

def self.sanitizePathComponent(component)
  # Remove leading and trailing slash
  component.gsub(/^\//, "").chomp("/")
end