Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/filepath/core_ext/array.rb

Instance Method Summary collapse

Instance Method Details

#as_pathFilePath

Note:

FIXME: #as_path should be #to_path but that method name is already used

Generates a path using the elements of an array as path segments.

[a, b, c].as_path is equivalent to FilePath.join(a, b, c).

Examples:

FilePath from an array of strings


["/", "foo", "bar"].as_path #=> </foo/bar>

FilePath from an array of strings and other FilePaths


server_dir = config["root_dir"] / "server"
["..", config_dir, "secret"].as_path #=> <../config/server/secret>

Returns:

  • (FilePath)

    a new path generated using the element as path segments



25
26
27
# File 'lib/filepath/core_ext/array.rb', line 25

def as_path
	FilePath.join(self)
end

#as_path_listFilePathList

Generates a path list from an array of paths.

The elements of the array must respond to #as_path.

ary.as_path is equivalent to FilePathList.new(ary).

Returns:

  • (FilePathList)

    a new path list containing the elements of the array as FilePaths

See Also:



43
44
45
# File 'lib/filepath/core_ext/array.rb', line 43

def as_path_list
	FilePathList.new(self)
end