Package org.jruby
Class RubyRational
java.lang.Object
org.jruby.RubyBasicObject
org.jruby.RubyObject
org.jruby.RubyNumeric
org.jruby.RubyRational
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<IRubyObject>
,InstanceVariables
,InternalVariables
,IRubyObject
,CoreObjectType
Ruby Rational impl (MRI: rational.c).
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jruby.RubyNumeric
RubyNumeric.InvalidIntegerException, RubyNumeric.NumberTooLargeException
Nested classes/interfaces inherited from class org.jruby.RubyObject
RubyObject.Data
Nested classes/interfaces inherited from class org.jruby.RubyBasicObject
RubyBasicObject.Finalizer
-
Field Summary
Fields inherited from class org.jruby.RubyNumeric
DBL_EPSILON
Fields inherited from class org.jruby.RubyObject
IVAR_INSPECTING_OBJECT_ALLOCATOR, OBJECT_ALLOCATOR, REIFYING_OBJECT_ALLOCATOR
Fields inherited from class org.jruby.RubyBasicObject
ALL_F, BASICOBJECT_ALLOCATOR, COMPARE_BY_IDENTITY_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, IS_OVERLAID_F, metaClass, NEVER, NIL_F, REFINED_MODULE_F, STAMP_OFFSET, TAINTED_F, UNDEF, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, USER8_F, USER9_F, USERA_F, VAR_TABLE_OFFSET, varTable, varTableStamp
Fields inherited from interface org.jruby.runtime.builtin.IRubyObject
NULL_ARRAY
-
Method Summary
Modifier and TypeMethodDescriptionasBigInteger
(ThreadContext context) Return a BigInteger representation of this numerical valuedouble
asDouble
(ThreadContext context) Return a double representation of this numerical valuelong
asLong
(ThreadContext context) Return the value of this numeric as a 64-bit long.ceil
(ThreadContext context) MRI: nurat_ceil_nceil
(ThreadContext context, IRubyObject n) static IRubyObject
convert
(ThreadContext context, IRubyObject recv, IRubyObject a1) nurat_s_convertstatic IRubyObject
convert
(ThreadContext context, IRubyObject clazz, IRubyObject[] args) Deprecated.static IRubyObject
convert
(ThreadContext context, IRubyObject recv, IRubyObject a1, IRubyObject a2) nurat_s_convertstatic IRubyObject
convert
(ThreadContext context, IRubyObject recv, IRubyObject a1, IRubyObject a2, IRubyObject kwargs) nurat_s_convertTries to convert this object to a Ruby Integer using the "to_int" method.convertToRational
(ThreadContext context) static RubyClass
createRationalClass
(ThreadContext context, RubyClass Numeric) denominator
(ThreadContext context) nurat_denominatoreql_p
(ThreadContext context, IRubyObject other) num_eqlfdiv
(ThreadContext context, IRubyObject other) nurat_fdivfloor
(ThreadContext context) MRI: nurat_floor_nfloor
(ThreadContext context, IRubyObject n) double
getDoubleValue
(ThreadContext context) Deprecated.This is overridden in the other concrete Java builtins to provide a fast way to determine what type they are.hash
(ThreadContext context) nurat_hashint
hashCode()
This override does not do "checked" dispatch since Object usually has #hash defined.idiv
(ThreadContext context, IRubyObject other) MRI: rb_int_idiv and overridesinspect
(ThreadContext context) nurat_inspectisNegative
(ThreadContext context) num_negative_pboolean
isNegativeNumber
(ThreadContext context) isPositive
(ThreadContext context) num_positive_pboolean
isPositiveNumber
(ThreadContext context) final boolean
isZero
(ThreadContext context) marshal_dump
(ThreadContext context) nurat_marshal_dumpmarshal_load
(ThreadContext context, IRubyObject arg) nurat_marshal_loadstatic RubyNumeric
newInstance
(ThreadContext context, RubyInteger num) static RubyNumeric
newInstance
(ThreadContext context, RubyInteger num, RubyInteger den) static IRubyObject
newInstance
(ThreadContext context, IRubyObject clazz, IRubyObject num) Deprecated.static IRubyObject
newInstance
(ThreadContext context, IRubyObject clazz, IRubyObject[] args) Deprecated.static IRubyObject
newInstance
(ThreadContext context, IRubyObject clazz, IRubyObject num, IRubyObject den) Deprecated.static RubyRational
newRational
(Ruby runtime, long x, long y) static IRubyObject
newRationalCanonicalize
(ThreadContext context, long x) static IRubyObject
newRationalCanonicalize
(ThreadContext context, long x, long y) static IRubyObject
newRationalCanonicalize
(ThreadContext context, RubyInteger x, RubyInteger y) rb_rational_newstatic IRubyObject
newRationalCanonicalize
(ThreadContext context, IRubyObject x, IRubyObject y) static IRubyObject
newRationalConvert
(ThreadContext context, IRubyObject x) rb_Rational1static IRubyObject
newRationalConvert
(ThreadContext context, IRubyObject x, IRubyObject y) rb_Rational/rb_Rational2static RubyRational
newRationalRaw
(Ruby runtime, IRubyObject x, IRubyObject y) rb_rational_rawnonzero_p
(ThreadContext context) num_nonzero_pnumerator
(ThreadContext context) nurat_numeratorstatic IRubyObject
numericQuo
(ThreadContext context, IRubyObject x, IRubyObject y) rb_numeric_quoop_abs
(ThreadContext context) nurat_absop_add
(ThreadContext context, IRubyObject other) Deprecated.op_ceil
(ThreadContext context) Deprecated.op_ceil
(ThreadContext context, IRubyObject n) Deprecated.op_cmp
(ThreadContext context, IRubyObject other) nurat_cmpop_coerce
(ThreadContext context, IRubyObject other) nurat_coercefinal RubyNumeric
op_div
(ThreadContext context, RubyInteger other) op_div
(ThreadContext context, IRubyObject other) nurat_divop_divmod
(ThreadContext context, IRubyObject other) nurat_divmodfinal IRubyObject
op_equal
(ThreadContext context, RubyInteger other) op_equal
(ThreadContext context, IRubyObject other) nurat_equal_pfinal IRubyObject
op_expt
(ThreadContext context, long other) op_expt
(ThreadContext context, IRubyObject other) nurat_exptop_fdiv
(ThreadContext context, IRubyObject other) Deprecated.op_floor
(ThreadContext context) Deprecated.op_floor
(ThreadContext context, IRubyObject n) Deprecated.op_idiv
(ThreadContext context, IRubyObject other) Deprecated.final RubyNumeric
op_minus
(ThreadContext context, RubyRational other) op_minus
(ThreadContext context, IRubyObject other) nurat_subop_mod
(ThreadContext context, IRubyObject other) op_mul
(ThreadContext context, RubyInteger other) op_mul
(ThreadContext context, IRubyObject other) nurat_mulfinal RubyNumeric
op_plus
(ThreadContext context, RubyRational other) op_plus
(ThreadContext context, IRubyObject other) nurat_addop_rem
(ThreadContext context, IRubyObject other) nurat_remop_sub
(ThreadContext context, IRubyObject other) Deprecated.op_uminus
(ThreadContext context) num_uminusstatic IRubyObject
rationalCanonicalize
(ThreadContext context, IRubyObject x) rationalize
(ThreadContext context, IRubyObject[] args) nurat_rationalizeround
(ThreadContext context) MRI: num_roundround
(ThreadContext context, IRubyObject n) round
(ThreadContext context, IRubyObject n, IRubyObject opts) roundCommon
(ThreadContext context, IRubyObject n, RoundingMode mode) static void
setCanonicalization
(boolean canonical) final int
signum()
Deprecated.final int
signum
(ThreadContext context) to_f
(ThreadContext context) nurat_to_fto_i
(ThreadContext context) to_r
(ThreadContext context) nurat_to_rto_s
(ThreadContext context) nurat_to_struncate
(ThreadContext context) MRI: nurat_truncatetruncate
(ThreadContext context, IRubyObject n) zero_p
(ThreadContext context) num_zero_pMethods inherited from class org.jruby.RubyNumeric
abs, abs2, arg, asInt, asNumeric, callCoerced, callCoerced, callCoerced, callCoerced, ceil, checkInt, checkInt, coerce, coerce, coerceBin, coerceBin, coerceBit, coerceBit, coerceCmp, coerceCmp, coerceFailed, coerceRelOp, coerceRelOp, coerceRescue, compareWithZero, conjugate, convertToRational, createNumericClass, dbl_cmp, dbl2ival, dbl2num, div, divmod, doCoerce, dup, finite_p, fix2int, fix2int, fix2long, fixable, float2long, float2ulong, floatStep, floatStepSize, floor, getBigIntegerValue, getCoerced, getDoubleValue, getIntValue, getLongValue, getRoundingMode, idiv, image, infinite_p, initialize_copy, int2fix, integer_p, integer_p, intervalStepSize, isNegative, isPositive, isReal, isZero, magnitude, modulo, negativeInt, negFixable, negFixable, newNumeric, num_imaginary, num2chr, num2dbl, num2dbl, num2fix, num2fix, num2int, num2long, num2ulong, numFuncall, numFuncall, numRemainder, op_not, op_num_equal, op_uplus, op_uplus, polar, posFixable, posFixable, positiveInt, quo, rbClone, rbClone, rbClone, rbClone, real, real_p, rect, remainder, round, scalar_p, singleton_method_added, step, str2fnum, str2fnum, str2fnum, str2inum, str2inum, str2inum, to_c, to_int, toJava, truncate
Methods inherited from class org.jruby.RubyObject
attachToObjectSpace, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, convertToType, dig, dig1, dig2, eqlInternal, equalInternal, equals, finishObjectClass, inspect, op_eqq, puts, specificEval, toRubyString, toString
Methods inherited from class org.jruby.RubyBasicObject
addFinalizer, addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkCallMethod, checkCallMethod, checkFrozen, checkStringType, cloneSetup, compareTo, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, dataGetStruct, dataGetStructChecked, dataWrapStruct, decode, display, dupFinalizer, dupSetup, ensureInstanceVariablesSettable, eql, eql_p, equal_p, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, finishBasicObjectClass, forEachInstanceVariable, forEachInstanceVariableName, freeze, frozen_p, getCurrentContext, getFFIHandle, getFlag, getInstanceEvalClass, getInstanceEvalClass, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariables, getJavaClass, getMarshalVariableList, getMetaClass, getMetaClass, getNativeHandle, getNativeTypeIndex, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getSingletonClassCloneAndAttach, getSingletonClassCloneAndAttach, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hash, hashyInspect, hasInstanceVariable, hasInstanceVariables, hasInternalVariable, hasVariables, id, infectBy, initialize, initialize_copy, inspect, inspectHashCode, instance_eval, instance_eval, instance_eval, instance_eval, instance_eval, instance_exec, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, isBuiltin, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isSpecialConst, isSpecialObject, isTaint, isTrue, isUntrusted, kind_of_p, makeMetaClass, makeMetaClass, makeMetaClassBootstrap, method, method, method, method_missing, methods, methods, nil_p, nonFixnumHashCode, nonFixnumHashCode, OBJ_INIT_COPY, objInitCopy, op_match, op_not_equal, op_not_match, private_methods, protected_methods, public_methods, rbInspect, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respondsTo, respondsToMissing, respondsToMissing, send, send, send, send, send, setFFIHandle, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setNativeHandle, setTaint, setUntrusted, setVariable, singleton_method, singleton_method, singleton_method_added, singleton_method_removed, singleton_method_undefined, singleton_methods, singletonClass, specificEval, specificEval, specificEval, specificEval, syncVariables, syncVariables, taint, taint, tainted_p, testFrozen, testFrozen, to_a, to_a, to_s, trust, type, untaint, untrust, untrusted_p, validateInstanceVariable, validateInstanceVariable, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnder
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.jruby.runtime.builtin.IRubyObject
checkStringType19, dup, marshalLiveVariables
-
Method Details
-
createRationalClass
-
newRationalRaw
rb_rational_raw -
newRationalCanonicalize
public static IRubyObject newRationalCanonicalize(ThreadContext context, RubyInteger x, RubyInteger y) rb_rational_new -
newRationalCanonicalize
public static IRubyObject newRationalCanonicalize(ThreadContext context, IRubyObject x, IRubyObject y) -
newRationalCanonicalize
-
newRationalCanonicalize
-
getNativeClassIndex
Description copied from class:RubyObject
This is overridden in the other concrete Java builtins to provide a fast way to determine what type they are. Will generally return a value from org.jruby.runtime.ClassIndex- Specified by:
getNativeClassIndex
in interfaceCoreObjectType
- Overrides:
getNativeClassIndex
in classRubyObject
- Returns:
- the ClassIndex of the native type this object was constructed from
- See Also:
-
setCanonicalization
public static void setCanonicalization(boolean canonical) -
newInstance
@Deprecated public static IRubyObject newInstance(ThreadContext context, IRubyObject clazz, IRubyObject[] args) Deprecated.nurat_s_new -
newInstance
@Deprecated public static IRubyObject newInstance(ThreadContext context, IRubyObject clazz, IRubyObject num) Deprecated. -
newInstance
@Deprecated public static IRubyObject newInstance(ThreadContext context, IRubyObject clazz, IRubyObject num, IRubyObject den) Deprecated. -
newInstance
-
newInstance
-
newRationalConvert
rb_Rational1 -
newRationalConvert
rb_Rational/rb_Rational2 -
newRational
-
rationalCanonicalize
-
convert
@Deprecated public static IRubyObject convert(ThreadContext context, IRubyObject clazz, IRubyObject[] args) Deprecated. -
convert
nurat_s_convert -
convert
public static IRubyObject convert(ThreadContext context, IRubyObject recv, IRubyObject a1, IRubyObject a2) nurat_s_convert -
convert
public static IRubyObject convert(ThreadContext context, IRubyObject recv, IRubyObject a1, IRubyObject a2, IRubyObject kwargs) nurat_s_convert -
numerator
nurat_numerator- Overrides:
numerator
in classRubyNumeric
-
denominator
nurat_denominator- Overrides:
denominator
in classRubyNumeric
-
getNumerator
-
getDenominator
-
convertToRational
- Overrides:
convertToRational
in classRubyNumeric
-
zero_p
Description copied from class:RubyNumeric
num_zero_p- Overrides:
zero_p
in classRubyNumeric
-
isZero
- Overrides:
isZero
in classRubyNumeric
-
nonzero_p
Description copied from class:RubyNumeric
num_nonzero_p- Overrides:
nonzero_p
in classRubyNumeric
-
isNegative
Description copied from class:RubyNumeric
num_negative_p- Overrides:
isNegative
in classRubyNumeric
-
isPositive
Description copied from class:RubyNumeric
num_positive_p- Overrides:
isPositive
in classRubyNumeric
-
isNegativeNumber
- Overrides:
isNegativeNumber
in classRubyNumeric
-
isPositiveNumber
- Overrides:
isPositiveNumber
in classRubyNumeric
-
signum
Deprecated. -
signum
-
op_plus
nurat_add- Overrides:
op_plus
in classRubyNumeric
-
op_plus
-
op_add
Deprecated. -
op_minus
nurat_sub- Overrides:
op_minus
in classRubyNumeric
-
op_minus
-
op_sub
Deprecated. -
op_uminus
Description copied from class:RubyNumeric
num_uminus- Overrides:
op_uminus
in classRubyNumeric
-
op_mul
nurat_mul -
op_mul
-
op_div
nurat_div -
op_div
-
fdiv
nurat_fdiv- Overrides:
fdiv
in classRubyNumeric
-
op_expt
nurat_expt -
op_expt
-
op_cmp
nurat_cmp- Overrides:
op_cmp
in classRubyNumeric
-
op_equal
nurat_equal_p- Specified by:
op_equal
in interfaceIRubyObject
- Overrides:
op_equal
in classRubyBasicObject
-
op_equal
-
eql_p
Description copied from class:RubyNumeric
num_eql- Overrides:
eql_p
in classRubyNumeric
-
op_coerce
nurat_coerce -
idiv
Description copied from class:RubyNumeric
MRI: rb_int_idiv and overrides- Overrides:
idiv
in classRubyNumeric
-
op_mod
-
op_divmod
nurat_divmod -
op_rem
nurat_rem -
op_abs
nurat_abs -
floor
MRI: nurat_floor_n- Overrides:
floor
in classRubyNumeric
-
floor
-
ceil
MRI: nurat_ceil_n- Overrides:
ceil
in classRubyNumeric
-
ceil
-
convertToInteger
Description copied from class:RubyBasicObject
Tries to convert this object to a Ruby Integer using the "to_int" method.- Specified by:
convertToInteger
in interfaceIRubyObject
- Overrides:
convertToInteger
in classRubyBasicObject
- Returns:
- an integer representation of this
-
to_i
-
asBigInteger
Description copied from class:RubyNumeric
Return a BigInteger representation of this numerical value- Overrides:
asBigInteger
in classRubyNumeric
- Parameters:
context
- the current thread context- Returns:
- a BigInteger
-
asLong
Description copied from class:RubyNumeric
Return the value of this numeric as a 64-bit long.- Overrides:
asLong
in classRubyNumeric
-
truncate
MRI: nurat_truncate- Overrides:
truncate
in classRubyNumeric
-
truncate
-
round
Description copied from class:RubyNumeric
MRI: num_round- Overrides:
round
in classRubyNumeric
-
round
-
round
-
roundCommon
-
to_f
nurat_to_f -
asDouble
Description copied from class:RubyNumeric
Return a double representation of this numerical value- Overrides:
asDouble
in classRubyNumeric
- Parameters:
context
- the current thread context- Returns:
- a double
-
getDoubleValue
Deprecated.USeasDouble(ThreadContext)
instead.- Parameters:
context
-- Returns:
-
to_r
nurat_to_r -
rationalize
nurat_rationalize -
hash
nurat_hash- Overrides:
hash
in classRubyBasicObject
- Parameters:
context
- the current thread context- Returns:
- the hash value
-
hashCode
public int hashCode()Description copied from class:RubyObject
This override does not do "checked" dispatch since Object usually has #hash defined.- Overrides:
hashCode
in classRubyObject
- Returns:
- the hash code
- See Also:
-
to_s
nurat_to_s- Overrides:
to_s
in classRubyBasicObject
-
inspect
nurat_inspect- Specified by:
inspect
in interfaceIRubyObject
- Overrides:
inspect
in classRubyBasicObject
-
marshal_dump
nurat_marshal_dump -
marshal_load
nurat_marshal_load -
numericQuo
rb_numeric_quo -
op_floor
Deprecated. -
op_floor
Deprecated. -
op_ceil
Deprecated. -
op_ceil
Deprecated. -
op_idiv
Deprecated. -
op_fdiv
Deprecated.
-
asDouble(ThreadContext)
instead.