Skip to content

Commit

Permalink
Showing 3 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/src/main/java/org/jruby/RubyFixnum.java
Original file line number Diff line number Diff line change
@@ -1378,11 +1378,17 @@ public IRubyObject denominator(ThreadContext context) {
return one(context.runtime);
}

@Override
public RubyRational convertToRational() {
final Ruby runtime = getRuntime();
return RubyRational.newRationalRaw(runtime, this, one(runtime));
}

@Override
public IRubyObject remainder(ThreadContext context, IRubyObject y) {
return numRemainder(context, y);
}

private static JavaSites.FixnumSites sites(ThreadContext context) {
return context.sites.Fixnum;
}
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/RubyInteger.java
Original file line number Diff line number Diff line change
@@ -797,6 +797,7 @@ public IRubyObject op_ge(ThreadContext context, IRubyObject other) {
public IRubyObject op_le(ThreadContext context, IRubyObject other) {
return RubyComparable.op_le(context, this, other);
}

@JRubyMethod(name = "remainder")
public IRubyObject remainder(ThreadContext context, IRubyObject dividend) {
return context.nil;
4 changes: 4 additions & 0 deletions core/src/main/java/org/jruby/RubyNumeric.java
Original file line number Diff line number Diff line change
@@ -803,6 +803,10 @@ public IRubyObject modulo(ThreadContext context, IRubyObject other) {
*/
@JRubyMethod(name = "remainder")
public IRubyObject remainder(ThreadContext context, IRubyObject y) {
return numRemainder(context, y);
}

public IRubyObject numRemainder(ThreadContext context, IRubyObject y) {
RubyNumeric x = this;
JavaSites.NumericSites sites = sites(context);
IRubyObject z = sites.op_mod.call(context, this, this, y);

0 comments on commit d735053

Please sign in to comment.