Sha256: 12a8452d690e24ab54f9d008419a51b4a69d6b47edec2d2beb16948dc64d19d3
Contents?: true
Size: 689 Bytes
Versions: 5
Compression:
Stored size: 689 Bytes
Contents
class File # Returns onlt the first portion of the directory of # a file path name. # # File.rootname('lib/jump.rb') #=> 'lib' # File.rootname('/jump.rb') #=> '/' # File.rootname('jump.rb') #=> '.' # # CREDIT: Trans # def self.rootname(path) # this should be fairly robust path_re = Regexp.new('[' + Regexp.escape(File::Separator + %q{\/}) + ']') head, tail = path.split(path_re, 2) return '.' if path == head return '/' if head.empty? return head end #def self.rootname( file_name ) # i = file_name.index('/') # if i # r = file_name[0...i] # r == '' ? '/' : r # else # '.' # end #end end
Version data entries
5 entries across 5 versions & 2 rubygems