pathname
pathname copied to clipboard
Please consider adding Pathname.home
Please consider adding Pathname.home for symmetry with Dir.home but returning a Pathname instead of a String, and to avoid having to use Pathname.new(Dir.home).
I don't understand why you don't use Pathname.new(Dir.home). What's the problem that?
It works, but is more verbose and I expected Pathname.home to work in the first place (POLA).
It'd be cool to have it aliased to ~.
class Pathname
class << self
def home(user_name = nil)
Pathname(Dir.home(user_name))
end
alias ~ home
end
end
p Pathname.~ #=> #<Pathname:/Users/knu>
p Pathname.~('root') #=> #<Pathname:/var/root>