Method: Path#add_extension

Defined in:
lib/path/parts.rb

#add_extension(ext) ⇒ Object Also known as: add_ext

Adds ext as an extension to path. Handle both extensions with or without leading dot. No-op if ext is empty?.

Path('file').add_extension('txt') # => #<Path file.txt>


46
47
48
49
# File 'lib/path/parts.rb', line 46

def add_extension(ext)
  return self if ext.to_s.empty?
  Path.new @path+dotted_ext(ext)
end