module EacRubyUtils::Fs
Public Class Methods
extname(path, limit = -1)
click to toggle source
A [File.extname] which find multiple extensions (Ex.: .tar.gz).
# File lib/eac_ruby_utils/fs/extname.rb, line 7 def extname(path, limit = -1) recursive_extension(::File.basename(path), limit) end
extname2(path)
click to toggle source
Shortcut to +extname(2)+.
# File lib/eac_ruby_utils/fs/extname.rb, line 12 def extname2(path) extname(path, 2) end
Private Class Methods
recursive_extension(basename, limit)
click to toggle source
# File lib/eac_ruby_utils/fs/extname.rb, line 18 def recursive_extension(basename, limit) return '' if limit.zero? m = /\A(.+)(\.[a-z][a-z0-9]*)\z/i.match(basename) if m "#{recursive_extension(m[1], limit - 1)}#{m[2]}" else '' end end