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



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

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:



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

def as_path_list
	FilepathList.new(self)
end