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.NumberTooLargeExceptionNested classes/interfaces inherited from class org.jruby.RubyObject
RubyObject.DataNested classes/interfaces inherited from class org.jruby.RubyBasicObject
RubyBasicObject.Finalizer -
Field Summary
Fields inherited from class org.jruby.RubyNumeric
DBL_EPSILONFields inherited from class org.jruby.RubyObject
IVAR_INSPECTING_OBJECT_ALLOCATOR, OBJECT_ALLOCATOR, REIFYING_OBJECT_ALLOCATORFields 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, varTableStampFields inherited from interface org.jruby.runtime.builtin.IRubyObject
NULL_ARRAY -
Method Summary
Modifier and TypeMethodDescriptionasBigInteger(ThreadContext context) Return a BigInteger representation of this numerical valuedoubleasDouble(ThreadContext context) Return a double representation of this numerical valuelongasLong(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 IRubyObjectconvert(ThreadContext context, IRubyObject recv, IRubyObject a1) nurat_s_convertstatic IRubyObjectconvert(ThreadContext context, IRubyObject clazz, IRubyObject[] args) Deprecated.static IRubyObjectconvert(ThreadContext context, IRubyObject recv, IRubyObject a1, IRubyObject a2) nurat_s_convertstatic IRubyObjectconvert(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 RubyClasscreateRationalClass(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) doublegetDoubleValue(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_hashinthashCode()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_pbooleanisNegativeNumber(ThreadContext context) isPositive(ThreadContext context) num_positive_pbooleanisPositiveNumber(ThreadContext context) final booleanisZero(ThreadContext context) marshal_dump(ThreadContext context) nurat_marshal_dumpmarshal_load(ThreadContext context, IRubyObject arg) nurat_marshal_loadstatic RubyNumericnewInstance(ThreadContext context, RubyInteger num) static RubyNumericnewInstance(ThreadContext context, RubyInteger num, RubyInteger den) static IRubyObjectnewInstance(ThreadContext context, IRubyObject clazz, IRubyObject num) Deprecated.static IRubyObjectnewInstance(ThreadContext context, IRubyObject clazz, IRubyObject[] args) Deprecated.static IRubyObjectnewInstance(ThreadContext context, IRubyObject clazz, IRubyObject num, IRubyObject den) Deprecated.static RubyRationalnewRational(Ruby runtime, long x, long y) static IRubyObjectnewRationalCanonicalize(ThreadContext context, long x) static IRubyObjectnewRationalCanonicalize(ThreadContext context, long x, long y) static IRubyObjectnewRationalCanonicalize(ThreadContext context, RubyInteger x, RubyInteger y) rb_rational_newstatic IRubyObjectnewRationalCanonicalize(ThreadContext context, IRubyObject x, IRubyObject y) static IRubyObjectnewRationalConvert(ThreadContext context, IRubyObject x) rb_Rational1static IRubyObjectnewRationalConvert(ThreadContext context, IRubyObject x, IRubyObject y) rb_Rational/rb_Rational2static RubyRationalnewRationalRaw(Ruby runtime, IRubyObject x, IRubyObject y) rb_rational_rawnonzero_p(ThreadContext context) num_nonzero_pnumerator(ThreadContext context) nurat_numeratorstatic IRubyObjectnumericQuo(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 RubyNumericop_div(ThreadContext context, RubyInteger other) op_div(ThreadContext context, IRubyObject other) nurat_divop_divmod(ThreadContext context, IRubyObject other) nurat_divmodfinal IRubyObjectop_equal(ThreadContext context, RubyInteger other) op_equal(ThreadContext context, IRubyObject other) nurat_equal_pfinal IRubyObjectop_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 RubyNumericop_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 RubyNumericop_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 IRubyObjectrationalCanonicalize(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 voidsetCanonicalization(boolean canonical) final intsignum()Deprecated.final intsignum(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, truncateMethods 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, toStringMethods 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, yieldUnderMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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:RubyObjectThis 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:
getNativeClassIndexin interfaceCoreObjectType- Overrides:
getNativeClassIndexin 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:
numeratorin classRubyNumeric
-
denominator
nurat_denominator- Overrides:
denominatorin classRubyNumeric
-
getNumerator
-
getDenominator
-
convertToRational
- Overrides:
convertToRationalin classRubyNumeric
-
zero_p
Description copied from class:RubyNumericnum_zero_p- Overrides:
zero_pin classRubyNumeric
-
isZero
- Overrides:
isZeroin classRubyNumeric
-
nonzero_p
Description copied from class:RubyNumericnum_nonzero_p- Overrides:
nonzero_pin classRubyNumeric
-
isNegative
Description copied from class:RubyNumericnum_negative_p- Overrides:
isNegativein classRubyNumeric
-
isPositive
Description copied from class:RubyNumericnum_positive_p- Overrides:
isPositivein classRubyNumeric
-
isNegativeNumber
- Overrides:
isNegativeNumberin classRubyNumeric
-
isPositiveNumber
- Overrides:
isPositiveNumberin classRubyNumeric
-
signum
Deprecated. -
signum
-
op_plus
nurat_add- Overrides:
op_plusin classRubyNumeric
-
op_plus
-
op_add
Deprecated. -
op_minus
nurat_sub- Overrides:
op_minusin classRubyNumeric
-
op_minus
-
op_sub
Deprecated. -
op_uminus
Description copied from class:RubyNumericnum_uminus- Overrides:
op_uminusin classRubyNumeric
-
op_mul
nurat_mul -
op_mul
-
op_div
nurat_div -
op_div
-
fdiv
nurat_fdiv- Overrides:
fdivin classRubyNumeric
-
op_expt
nurat_expt -
op_expt
-
op_cmp
nurat_cmp- Overrides:
op_cmpin classRubyNumeric
-
op_equal
nurat_equal_p- Specified by:
op_equalin interfaceIRubyObject- Overrides:
op_equalin classRubyBasicObject
-
op_equal
-
eql_p
Description copied from class:RubyNumericnum_eql- Overrides:
eql_pin classRubyNumeric
-
op_coerce
nurat_coerce -
idiv
Description copied from class:RubyNumericMRI: rb_int_idiv and overrides- Overrides:
idivin classRubyNumeric
-
op_mod
-
op_divmod
nurat_divmod -
op_rem
nurat_rem -
op_abs
nurat_abs -
floor
MRI: nurat_floor_n- Overrides:
floorin classRubyNumeric
-
floor
-
ceil
MRI: nurat_ceil_n- Overrides:
ceilin classRubyNumeric
-
ceil
-
convertToInteger
Description copied from class:RubyBasicObjectTries to convert this object to a Ruby Integer using the "to_int" method.- Specified by:
convertToIntegerin interfaceIRubyObject- Overrides:
convertToIntegerin classRubyBasicObject- Returns:
- an integer representation of this
-
to_i
-
asBigInteger
Description copied from class:RubyNumericReturn a BigInteger representation of this numerical value- Overrides:
asBigIntegerin classRubyNumeric- Parameters:
context- the current thread context- Returns:
- a BigInteger
-
asLong
Description copied from class:RubyNumericReturn the value of this numeric as a 64-bit long.- Overrides:
asLongin classRubyNumeric
-
truncate
MRI: nurat_truncate- Overrides:
truncatein classRubyNumeric
-
truncate
-
round
Description copied from class:RubyNumericMRI: num_round- Overrides:
roundin classRubyNumeric
-
round
-
round
-
roundCommon
-
to_f
nurat_to_f -
asDouble
Description copied from class:RubyNumericReturn a double representation of this numerical value- Overrides:
asDoublein 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:
hashin classRubyBasicObject- Parameters:
context- the current thread context- Returns:
- the hash value
-
hashCode
public int hashCode()Description copied from class:RubyObjectThis override does not do "checked" dispatch since Object usually has #hash defined.- Overrides:
hashCodein classRubyObject- Returns:
- the hash code
- See Also:
-
to_s
nurat_to_s- Overrides:
to_sin classRubyBasicObject
-
inspect
nurat_inspect- Specified by:
inspectin interfaceIRubyObject- Overrides:
inspectin 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.