Method: Filepath#with_filename

Defined in:
lib/filepath/filepath.rb

#with_filename(new_path) ⇒ Filepath Also known as: with_basename, replace_filename, replace_basename

Replace the path filename with the supplied path.

Examples:


post = "posts/2012-02-16-hello-world/index.md".as_path
style = post.with_filename("style.css")
style.to_s #=> "posts/2012-02-16-hello-world/style.css"

Parameters:

  • new_path (Filepath, String)

    the path to be put in place of the current filename

Returns:

  • (Filepath)

    a path with the supplied path instead of the current filename

See Also:



224
225
226
227
# File 'lib/filepath/filepath.rb', line 224

def with_filename(new_path)
	dir = self.parent_dir
	return dir / new_path
end