Sha256: 135aa65aa02c6579dfbeb51a9adb09ffe5f37a251232959cf467668f1a729b6f
Contents?: true
Size: 1.1 KB
Versions: 28
Compression:
Stored size: 1.1 KB
Contents
# -*- encoding: UTF-8 -*- require 'pathname' module CSD module Extensions module Core # This module comprises extensions to the Dir object. # module Dir # This method returns the names of all children-directories (i.e. first generation of descendants) # of a directory in either an +Array+, or in a block. It does the same thing as # +Pathname.children_directories+ but returns just the name and not the entire path to the children directories. # # ==== Examples # # Dir.directories('/home/user') # => ['Desktop', 'Documents', ...] # # Dir.directories('/home/user') do |dir| # puts dir # end # def directories(path, &block) if block_given? ::Pathname.new(path).children_directories { |pathname| yield pathname.basename.to_s } else ::Pathname.new(path).children_directories.map { |pathname| pathname.basename.to_s } end end end end end end class Dir #:nodoc: extend CSD::Extensions::Core::Dir end
Version data entries
28 entries across 28 versions & 1 rubygems