Skip to content

Commit

Permalink
Merge pull request #2478 from Who828/methods_audit
Browse files Browse the repository at this point in the history
Implemented Enumerator#peek_values and Enumerator#next_values
  • Loading branch information
enebo committed Jan 18, 2015
2 parents 41e4586 + c41b90c commit a1e5645
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion core/src/main/java/org/jruby/RubyEnumerator.java
Expand Up @@ -474,7 +474,21 @@ public synchronized IRubyObject peek(ThreadContext context) {

return nexter.peek();
}


@JRubyMethod(name = "peek_values")
public synchronized IRubyObject peekValues(ThreadContext context) {
ensureNexter(context);

return RubyArray.newArray(context.runtime, nexter.peek());
}

@JRubyMethod(name = "next_values")
public synchronized IRubyObject nextValues(ThreadContext context) {
ensureNexter(context);

return RubyArray.newArray(context.runtime, nexter.next());
}

private void ensureNexter(ThreadContext context) {
if (nexter == null) {
if (Options.ENUMERATOR_LIGHTWEIGHT.load()) {
Expand Down

0 comments on commit a1e5645

Please sign in to comment.