Method: Array#as_path

Defined in:
lib/filepath/core_ext/array.rb

#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



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

def as_path
	Filepath.join(self)
end