Sha256: 9179587b3ab62eb22bc0585ae9f99704f9f62c6878fae3f7db7da27865ae12c6
Contents?: true
Size: 875 Bytes
Versions: 12
Compression:
Stored size: 875 Bytes
Contents
class File def self.basename_wo_ext(s) bn = File.basename(s) if bn =~ /^(.*)\.([^.]*)$/ $1 else bn end end # # File.extname_wo_dot("x.y") => "y" # File.extname_wo_dot("x.") => "" # File.extname_wo_dot(".y") => "" # File.extname_wo_dot("x") => "" # def self.extname_wo_dot(s) File.extname(s) =~ /^\.([^.]*)$/ ? $1 : "" end end module File::Etest def test_extname_wo_dot assert_equal "y", File.extname_wo_dot("x.y") assert_equal "", File.extname_wo_dot("x.") assert_equal "", File.extname_wo_dot(".y") assert_equal "", File.extname_wo_dot("x") end def test_basename_wo_ext assert_equal "x", File.basename_wo_ext("x.y") assert_equal "x", File.basename_wo_ext("x.") assert_equal "", File.basename_wo_ext(".y") assert_equal "x", File.basename_wo_ext("x") end end if VEX_TEST == "base"
Version data entries
12 entries across 12 versions & 1 rubygems