Sha256: d4064e35e1d86ccd36488a6f946938339b2475ddd23f92a6ac5ae840ebecb54f

Contents?: true

Size: 473 Bytes

Versions: 10

Compression:

Stored size: 473 Bytes

Contents

class File

  # Splits a file path into an array of individual path components.
  # This differs from <tt>File.split</tt>, which divides the path into
  # only two parts, directory path and basename.
  #
  #   File.split_all("a/b/c") =>  ['a', 'b', 'c']
  #
  # CREDIT: Trans

  def self.split_all(path)
    head, tail = File.split(path)
    return [tail] if head == '.' || tail == '/'
    return [head, tail] if head == '/'
    return split_all(head) + [tail]
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
facets-2.8.4 lib/core/facets/file/split_all.rb
facets-2.8.3 lib/core/facets/file/split_all.rb
facets-2.8.2 lib/core/facets/file/split_all.rb
facets-2.8.1 lib/core/facets/file/split_all.rb
facets-2.8.0 lib/core/facets/file/split_all.rb
facets-2.7.0 lib/core/facets/file/split_all.rb
facets-2.6.0 lib/core/facets/file/split_all.rb
facets-2.5.0 lib/core/facets/file/split_all.rb
facets-2.5.1 lib/core/facets/file/split_all.rb
facets-2.5.2 lib/core/facets/file/split_all.rb