Method: String#ext

Defined in:
lib/lbt/utils.rb

#ext(suffix) ⇒ Object

Return a string with the new suffix. If the suffix is illegal, nil is returned. Be careful that the suffix begins with a period.

It redefines itself if it has been defined. For example, rake defines ext method.



15
16
17
18
19
# File 'lib/lbt/utils.rb', line 15

def ext(suffix)
  return nil unless suffix.is_a?(String) && /^\.\w+$/ =~ suffix
  s = File.extname(self)
  self.sub(/#{s}$/, suffix)
end