Sha256: ff517e279b4b35ef7cfa32261c188651732a6eb81e11a6c2f152c883ce32fb45

Contents?: true

Size: 1.21 KB

Versions: 12

Compression:

Stored size: 1.21 KB

Contents

#--
# Author::    Nolan Cafferky
# Copyright:: Copyright (c) 2007 QualitySmith, Inc.
# License::   Ruby License
# Submit to Facets?:: Yes.
#++


class Dir
  # Much like each(), except the "." and ".." special files
  # are ignored.
  def each_child
    each do |file|
      yield file if file != "." and file != ".."
    end
  end
end


#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
=begin test
require 'test/unit'

require 'fileutils'

class TheTest < Test::Unit::TestCase
  def setup
    @base_path = "dir_extensions_test_test_each_child"
    make_test_files @base_path
  end
  def teardown
    FileUtils.remove_entry_secure @base_path
  end

  def test_each_child
    Dir.open(@base_path) do |d|
      results = []
      d.each_child { |file| results << file }
      assert_equal 3, results.size
      assert results.include?("foo")
      assert results.include?("bar")
      assert results.include?("foobar")
    end
  end

  def make_test_files base_path
    Dir.mkdir(      base_path)
    FileUtils.touch(base_path + "/foo")
    FileUtils.touch(base_path + "/bar")
    Dir.mkdir(      base_path + "/foobar")
    FileUtils.touch(base_path + "/foobar/baz")
  end
end
=end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
quality_extensions-1.4.0 lib/quality_extensions/dir/each_child.rb
quality_extensions-1.3.2 lib/quality_extensions/dir/each_child.rb
quality_extensions-1.3.1 lib/quality_extensions/dir/each_child.rb
quality_extensions-1.3.0 lib/quality_extensions/dir/each_child.rb
quality_extensions-1.1.6 lib/quality_extensions/dir/each_child.rb
quality_extensions-1.0.3 lib/quality_extensions/dir/each_child.rb
quality_extensions-1.1.1 lib/quality_extensions/dir/each_child.rb
quality_extensions-1.1.2 lib/quality_extensions/dir/each_child.rb
quality_extensions-1.1.3 lib/quality_extensions/dir/each_child.rb
quality_extensions-1.1.0 lib/quality_extensions/dir/each_child.rb
quality_extensions-1.1.4 lib/quality_extensions/dir/each_child.rb
quality_extensions-1.0.0 lib/quality_extensions/dir/each_child.rb