Top Description Fields Constructors Methods
org.jruby

public Class RubyRational

extends RubyNumeric
Class Inheritance
Annotations
@JRubyClass
name:Rational
parent:Numeric
Imports
java.io.IOException, java.math.BigInteger, .RoundingMode, org.jcodings.specific.ASCIIEncoding, .USASCIIEncoding, org.jruby.anno.JRubyClass, .JRubyMethod, org.jruby.api.Convert, .JRubyAPI, org.jruby.ast.util.ArgsUtil, org.jruby.exceptions.RaiseException, org.jruby.runtime.Arity, .CallSite, .ClassIndex, .JavaSites, .ObjectMarshal, .ThreadContext, .Visibility, org.jruby.runtime.builtin.IRubyObject, org.jruby.runtime.marshal.MarshalDumper, .MarshalLoader, org.jruby.util.ByteList, .Numeric, .TypeConverter, org.jruby.util.io.RubyInputStream, .RubyOutputStream

Ruby Rational impl (MRI: rational.c).

Field Summary

Modifier and TypeField and Description
private static boolean
canonicalization

nurat_canonicalization

private RubyInteger
private static final long
private RubyInteger
private static final ObjectMarshal<T>
Inherited from org.jruby.RubyNumeric:
DBL_EPSILON

Constructor Summary

AccessConstructor and Description
private
private
RubyRational(Ruby runtime, RubyClass clazz)

Method Summary

Modifier and TypeMethod and Description
public BigInteger
asBigInteger(ThreadContext
the current thread context
context
)

Overrides org.jruby.RubyNumeric.asBigInteger.

Return a BigInteger representation of this numerical value

public double
asDouble(ThreadContext
the current thread context
context
)

Overrides org.jruby.RubyNumeric.asDouble.

Return a double representation of this numerical value

public long
asLong(ThreadContext context)

Overrides org.jruby.RubyNumeric.asLong.

Return the value of this numeric as a 64-bit long.

private static RubyNumeric
canonicalizeInternal(ThreadContext context, RubyClass clazz, RubyInteger num, RubyInteger den)

nurat_s_canonicalize_internal

private static RubyNumeric
canonicalizeInternal(ThreadContext context, RubyClass clazz, long num, long den)

private static RubyNumeric
canonicalizeInternalNoReduce(ThreadContext context, RubyClass clazz, RubyInteger num, RubyInteger den)

nurat_s_canonicalize_internal_no_reduce

private static boolean
public IRubyObject
ceil(ThreadContext context)

Overrides org.jruby.RubyNumeric.ceil.

MRI: nurat_ceil_n

public IRubyObject
public static IRubyObject
convert(ThreadContext context, IRubyObject clazz, IRubyObject[] args)
Deprecated

public static IRubyObject
convert(ThreadContext context, IRubyObject recv, IRubyObject a1)

nurat_s_convert

public static IRubyObject
convert(ThreadContext context, IRubyObject recv, IRubyObject a1, IRubyObject a2)

nurat_s_convert

public static IRubyObject
convert(ThreadContext context, IRubyObject recv, IRubyObject a1, IRubyObject a2, IRubyObject kwargs)

nurat_s_convert

private static IRubyObject
convertCommon(ThreadContext context, RubyClass clazz, IRubyObject a1, IRubyObject a2, boolean raise)

public RubyInteger
convertToInteger()

Overrides org.jruby.RubyBasicObject.convertToInteger.

Implements org.jruby.runtime.builtin.IRubyObject.convertToInteger.

Tries to convert this object to a Ruby Integer using the "to_int" method.

public RubyRational
public static RubyClass
public IRubyObject
denominator(ThreadContext context)

Overrides org.jruby.RubyNumeric.denominator.

nurat_denominator

private IRubyObject
public IRubyObject
eql_p(ThreadContext context, IRubyObject other)

Overrides org.jruby.RubyNumeric.eql_p.

num_eql

private static RubyNumeric
f_addsub(ThreadContext context, RubyClass metaClass, RubyInteger anum, RubyInteger aden, RubyInteger bnum, RubyInteger bden, final boolean plus)

f_addsub

private static RubyInteger
f_imul(ThreadContext context, long a, long b)

f_imul

private static RubyNumeric
f_muldiv(ThreadContext context, RubyClass clazz, RubyInteger anum, RubyInteger aden, RubyInteger bnum, RubyInteger bden, final boolean mult)

f_muldiv

public IRubyObject
fdiv(ThreadContext context, IRubyObject other)

Overrides org.jruby.RubyNumeric.fdiv.

nurat_fdiv

private RubyNumeric
fix_expt(ThreadContext context, RubyInteger other, final int sign)

public IRubyObject
floor(ThreadContext context)

Overrides org.jruby.RubyNumeric.floor.

MRI: nurat_floor_n

public IRubyObject
public RubyInteger
public double
public ClassIndex
getNativeClassIndex()

Overrides org.jruby.RubyObject.getNativeClassIndex.

Implements org.jruby.runtime.marshal.CoreObjectType.getNativeClassIndex.

This is overridden in the other concrete Java builtins to provide a fast way to determine what type they are.

public RubyInteger
public RubyFixnum
hash(ThreadContext
the current thread context
context
)

Overrides org.jruby.RubyBasicObject.hash.

nurat_hash

public int
hashCode()

Overrides org.jruby.RubyObject.hashCode.

This override does not do "checked" dispatch since Object usually has #hash defined.

public IRubyObject
idiv(ThreadContext context, IRubyObject other)

Overrides org.jruby.RubyNumeric.idiv.

MRI: rb_int_idiv and overrides

public RubyString
private static RubyInteger
intCheck(ThreadContext context, IRubyObject num)

nurat_int_check

private static CallSite
pack-priv static IRubyObject
intValue(ThreadContext context, IRubyObject num, boolean raise)

nurat_int_value

public IRubyObject
isNegative(ThreadContext context)

Overrides org.jruby.RubyNumeric.isNegative.

num_negative_p

public boolean
public IRubyObject
isPositive(ThreadContext context)

Overrides org.jruby.RubyNumeric.isPositive.

num_positive_p

public boolean
public final boolean
public IRubyObject
marshal_dump(ThreadContext context)

nurat_marshal_dump

public IRubyObject
marshal_load(ThreadContext context, IRubyObject arg)

nurat_marshal_load

private IRubyObject
private IRubyObject
private RubyInteger
public static IRubyObject
newInstance(ThreadContext context, IRubyObject clazz, IRubyObject[] args)
Deprecated

nurat_s_new

public static IRubyObject
newInstance(ThreadContext context, IRubyObject clazz, IRubyObject num)
Deprecated

pack-priv static IRubyObject
pack-priv static IRubyObject
newInstance(ThreadContext context, RubyClass clazz, IRubyObject num, boolean raise)

public static IRubyObject
newInstance(ThreadContext context, IRubyObject clazz, IRubyObject num, IRubyObject den)
Deprecated

pack-priv static IRubyObject
pack-priv static IRubyObject
newInstance(ThreadContext context, RubyClass clazz, IRubyObject num, IRubyObject den, boolean raise)

pack-priv static RubyNumeric
public static RubyNumeric
public static RubyNumeric
public static RubyRational
newRational(Ruby runtime, long x, long y)

pack-priv static RubyRational
private static RubyRational
newRationalBang(ThreadContext context, RubyClass clazz, IRubyObject x, IRubyObject y)

f_rational_new_bang2

private static RubyRational
newRationalBang(ThreadContext context, RubyClass clazz, IRubyObject x)

f_rational_new_bang1

private static RubyRational
newRationalBang(ThreadContext context, RubyClass clazz, long x)

pack-priv static RubyNumeric
public static IRubyObject
public static IRubyObject
public static IRubyObject
newRationalCanonicalize(ThreadContext context, long x, long y)

public static IRubyObject
public static IRubyObject
public static IRubyObject
newRationalConvert(ThreadContext context, IRubyObject x, IRubyObject y)

rb_Rational/rb_Rational2

pack-priv static RubyNumeric
private static RubyNumeric
newRationalNoReduce(ThreadContext context, RubyClass clazz, RubyInteger x, RubyInteger y)

f_rational_new_no_reduce2

public static RubyRational
newRationalRaw(Ruby runtime, IRubyObject x, IRubyObject y)

rb_rational_raw

pack-priv static RubyRational
newRationalRaw(Ruby runtime, IRubyObject x)

rb_rational_raw1

public IRubyObject
nonzero_p(ThreadContext context)

Overrides org.jruby.RubyNumeric.nonzero_p.

num_nonzero_p

public IRubyObject
numerator(ThreadContext context)

Overrides org.jruby.RubyNumeric.numerator.

nurat_numerator

public static IRubyObject
numericQuo(ThreadContext context, IRubyObject x, IRubyObject y)

rb_numeric_quo

public IRubyObject
op_abs(ThreadContext context)

nurat_abs

public IRubyObject
op_add(ThreadContext context, IRubyObject other)
Deprecated

public IRubyObject
op_ceil(ThreadContext context)
Deprecated

public IRubyObject
op_ceil(ThreadContext context, IRubyObject n)
Deprecated

public IRubyObject
op_cmp(ThreadContext context, IRubyObject other)

Overrides org.jruby.RubyNumeric.op_cmp.

nurat_cmp

public IRubyObject
op_coerce(ThreadContext context, IRubyObject other)

nurat_coerce

public IRubyObject
op_div(ThreadContext context, IRubyObject other)

nurat_div

public final RubyNumeric
public IRubyObject
op_divmod(ThreadContext context, IRubyObject other)

nurat_divmod

public IRubyObject
public final IRubyObject
pack-priv final RubyBoolean
public IRubyObject
op_expt(ThreadContext context, IRubyObject other)

nurat_expt

public final IRubyObject
op_expt(ThreadContext context, long other)

public IRubyObject
op_fdiv(ThreadContext context, IRubyObject other)
Deprecated

public IRubyObject
op_floor(ThreadContext context)
Deprecated

public IRubyObject
op_floor(ThreadContext context, IRubyObject n)
Deprecated

public IRubyObject
op_idiv(ThreadContext context, IRubyObject other)
Deprecated

public IRubyObject
public final RubyNumeric
public IRubyObject
public IRubyObject
op_mul(ThreadContext context, IRubyObject other)

nurat_mul

public IRubyObject
public IRubyObject
op_plus(ThreadContext context, IRubyObject other)

Overrides org.jruby.RubyNumeric.op_plus.

nurat_add

public final RubyNumeric
public IRubyObject
op_rem(ThreadContext context, IRubyObject other)

nurat_rem

public IRubyObject
op_sub(ThreadContext context, IRubyObject other)
Deprecated

public IRubyObject
private static IRubyObject
public static IRubyObject
public IRubyObject
rationalize(ThreadContext context, IRubyObject[] args)

nurat_rationalize

public IRubyObject
round(ThreadContext context)

Overrides org.jruby.RubyNumeric.round.

MRI: num_round

public IRubyObject
public IRubyObject
public IRubyObject
private RubyInteger
private RubyInteger
private RubyInteger
public static void
setCanonicalization(boolean canonical)

public final int
signum()
Deprecated since 10.0.

public final int
private static JavaSites.RationalSites
sites(ThreadContext context)

Hides org.jruby.RubyNumeric.sites.

Retrieve the call sites for this class.

pack-priv static IRubyObject[]
str_to_r_internal(final ThreadContext context, final RubyString str, boolean raise)

private static IRubyObject
str_to_r_strict(ThreadContext context, RubyString str, boolean raise)

public IRubyObject
to_f(ThreadContext context)

nurat_to_f

public IRubyObject
public IRubyObject
to_r(ThreadContext context)

nurat_to_r

public RubyString
to_s(ThreadContext context)

Overrides org.jruby.RubyBasicObject.to_s.

nurat_to_s

public IRubyObject
truncate(ThreadContext context)

Overrides org.jruby.RubyNumeric.truncate.

MRI: nurat_truncate

public IRubyObject
public IRubyObject
zero_p(ThreadContext context)

Overrides org.jruby.RubyNumeric.zero_p.

num_zero_p

Inherited from org.jruby.RubyNumeric:
absabs2argasIntasNumericcallCoercedcallCoercedcallCoercedcallCoercedceilcheckIntcheckIntcoercecoercecoerceBincoerceBincoerceBitcoerceBitcoerceCmpcoerceCmpcoerceFailedcoerceRelOpcoerceRelOpcoerceRescuecompareNumberWithZerocompareWithZeroconjugateconvertToRationalcreateNumericClassdbl2ivaldbl2numdbl_cmpdivdivmoddoCoercedupfinite_pfix2intfix2intfix2longfixablefloat2longfloat2ulongfloatStepfloatStepSizefloorgetBigIntegerValuegetCoercedgetDoubleValuegetIntValuegetLongValuegetRoundingModeidivimageinfinite_pinitialize_copyint2fixinteger_pinteger_pintervalStepSizeisNegativeisPositiveisRealisZeromagnitudemodulomodulonegativeIntnegFixablenegFixablenewNumericnum2chrnum2dblnum2dblnum2fixnum2fixnum2intnum2longnum2ulongnum_imaginarynumFuncallnumFuncallnumRemainderop_notop_num_equalop_uplusop_upluspolarposFixableposFixablepositiveIntquorbClonerbClonerbClonerbClonerealreal_prectremainderroundscalar_psingleton_method_addedstepstr2fnumstr2fnumstr2fnumstr2inumstr2inumstr2inumto_cto_inttoJavatruncate