Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e8ae24043417
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 665521df5c25
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Nov 16, 2016

  1. Add Dir.empty?

    kcdragon committed Nov 16, 2016
    Copy the full SHA
    33e3ee9 View commit details
  2. Merge pull request #4301 from kcdragon/md/feature/add-dir-empty

    Add `Dir.empty?`
    headius authored Nov 16, 2016
    Copy the full SHA
    665521d View commit details
Showing with 9 additions and 0 deletions.
  1. +9 −0 core/src/main/java/org/jruby/RubyDir.java
9 changes: 9 additions & 0 deletions core/src/main/java/org/jruby/RubyDir.java
Original file line number Diff line number Diff line change
@@ -624,6 +624,15 @@ public IRubyObject rewind() {
return this;
}

@JRubyMethod(name = "empty?", meta = true)
public static IRubyObject empty_p(ThreadContext context, IRubyObject recv, IRubyObject arg) {
Ruby runtime = context.runtime;
RubyString path = StringSupport.checkEmbeddedNulls(runtime, RubyFile.get_path(context, arg));
RubyFileStat fileStat = runtime.newFileStat(path.asJavaString(), false);
boolean isDirectory = fileStat.directory_p().isTrue();
return runtime.newBoolean(isDirectory && entries19(context, recv, arg).getLength() <= 2);
}

@JRubyMethod(name = "exist?", meta = true)
public static IRubyObject exist(ThreadContext context, IRubyObject recv, IRubyObject arg) {
Ruby runtime = context.runtime;