Sha256: a1db62cbf7cca9ca4f97938827197d47507e68add3bed32b739e0d54b77cc59e

Contents?: true

Size: 393 Bytes

Versions: 14

Compression:

Stored size: 393 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')      #=> '.'
  #

  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

14 entries across 14 versions & 1 rubygems

Version Path
facets-1.4.2 lib/facets/core/file/self/rootname.rb
facets-1.4.3 lib/facets/core/file/self/rootname.rb
facets-1.4.4 lib/facets/core/file/self/rootname.rb
facets-1.4.5 lib/facets/core/file/self/rootname.rb
facets-1.7.38 lib/facets/core/file/self/rootname.rb
facets-1.7.0 lib/facets/core/file/self/rootname.rb
facets-1.7.30 lib/facets/core/file/self/rootname.rb
facets-1.7.46 lib/facets/core/file/self/rootname.rb
facets-1.8.0 lib/facets/core/file/self/rootname.rb
facets-1.8.49 lib/facets/core/file/self/rootname.rb
facets-1.8.51 lib/facets/core/file/self/rootname.rb
facets-1.8.20 lib/facets/core/file/self/rootname.rb
facets-1.8.54 lib/facets/core/file/self/rootname.rb
facets-1.8.8 lib/facets/core/file/self/rootname.rb