Class: Pathname

Inherits:
Object show all
Defined in:
lib/modalsupport/pathname.rb

Instance Method Summary collapse

Instance Method Details

#sub_ext(new_ext) ⇒ Object

This method is available in Ruby >= 1.9.1



6
7
8
9
10
11
12
# File 'lib/modalsupport/pathname.rb', line 6

def sub_ext(new_ext)
  # this is how I would do it:
  #   new_ext = ".#{new_ext}" unless new_ext[0,1]=='.'
  #   Pathname.new to_s[/.*(?=\..+$)/]+new_ext
  # but we'll try to be compatible with the standars library method
  Pathname(self.to_s.chomp(extname) + new_ext)
end