Sha256: ac86137624428ff7116746ce77b3c3d34ace0e76a979c9c8700a908c5c9aeeed
Contents?: true
Size: 728 Bytes
Versions: 26
Compression:
Stored size: 728 Bytes
Contents
# 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. # # split_all("a/b/c") => ['a', 'b', 'c'] # def File.split_all(path) head, tail = File.split(path) return [tail] if head == '.' || tail == '/' return [head, tail] if head == '/' return split_all(head) + [tail] end # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TCFile < Test::Unit::TestCase def test_split_all fp = "this/is/test" assert_equal( ['this', 'is', 'test'], File.split_all(fp) ) end end =end
Version data entries
26 entries across 26 versions & 1 rubygems