Top Description Inners Fields Constructors Methods
org.jruby

public Class RubyRandom

extends RubyRandomBase
Class Inheritance
Annotations
@JRubyClass
name:Random
Imports
java.math.BigInteger, org.jruby.anno.JRubyClass, .JRubyMethod, org.jruby.runtime.ObjectAllocator, .ThreadContext, org.jruby.runtime.builtin.IRubyObject, org.jruby.util.Random

Implementation of the Random class.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
pack-priv static class
RubyRandom.RandomType

Internal API, subject to change.

Field Summary

Modifier and TypeField and Description
private static final int
Inherited from org.jruby.RubyRandomBase:
random

Constructor Summary

AccessConstructor and Description
pack-priv
RubyRandom(Ruby runtime, RubyClass rubyClass)

pack-priv
RubyRandom(Ruby runtime, RubyClass rubyClass, RubyRandom.RandomType randomType)

Method Summary

Modifier and TypeMethod and Description
public static IRubyObject
public static RubyClass
public RubyRandom.RandomType
public IRubyObject
initialize_copy(ThreadContext
the thread context
context
,
IRubyObject
the original
orig
)

Overrides org.jruby.RubyBasicObject.initialize_copy.

Initializes this object as a copy of the original, that is the parameter to this object.

public static IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public static RubyRandom
newRandom(Ruby runtime, RubyClass randomClass, IRubyObject seed)
Deprecated since 10.0.

public static RubyRandom
newRandom(ThreadContext context, RubyClass randomClass, IRubyObject seed)

public static IRubyObject
public IRubyObject
op_equal(ThreadContext context, IRubyObject obj)

Overrides org.jruby.RubyBasicObject.op_equal.

Implements org.jruby.runtime.builtin.IRubyObject.op_equal.

rb_obj_equal Will by default use identity equality to compare objects.

public static IRubyObject
rand(ThreadContext context, IRubyObject recv, IRubyObject[] args)
Deprecated

public static IRubyObject
public static IRubyObject
pack-priv static IRubyObject
pack-priv static IRubyObject
randKernel(ThreadContext context, IRubyObject[] args)
Deprecated

public IRubyObject
randObj(ThreadContext context, IRubyObject[] args)
Deprecated

public static RubyBignum
randomSeed(Ruby runtime)

public static BigInteger
public static IRubyObject
public static IRubyObject
public static IRubyObject
public static IRubyObject
public static IRubyObject
public static IRubyObject
public static IRubyObject
public IRubyObject
public static IRubyObject
Inherited from org.jruby.RubyRandomBase:
bytesbytesCommoncheckRandomNumbergetBytesgetDefaultRandgetDefaultRandomgetIntBigIntegerBufferinitializeinvalidArgumentrandrandrandFloatrandFloatrandIntrandLimitedrandLimitedrandLimitedFixnumInnerrandomLongLimitedrandomRealrandRandomrandRandomrangeValuesseedsetIntBigIntegerBuffertryGetRandomType

Field Detail

DEFAULT_SEED_CNTback to summary
private static final int DEFAULT_SEED_CNT

Constructor Detail

RubyRandomback to summary
pack-priv RubyRandom(Ruby runtime, RubyClass rubyClass)
RubyRandomback to summary
pack-priv RubyRandom(Ruby runtime, RubyClass rubyClass, RubyRandom.RandomType randomType)

Method Detail

bytesback to summary
public static IRubyObject bytes(ThreadContext context, IRubyObject recv, IRubyObject arg)
Annotations
@JRubyMethod
meta:true
createRandomClassback to summary
public static RubyClass createRandomClass(ThreadContext context, RubyClass Object)
Annotations
@SuppressWarnings:deprecation
getRandomTypeback to summary
public RubyRandom.RandomType getRandomType()
initialize_copyback to summary
public IRubyObject initialize_copy(ThreadContext context, IRubyObject orig)

Overrides org.jruby.RubyBasicObject.initialize_copy.

Doc from org.jruby.RubyBasicObject.initialize_copy.

Initializes this object as a copy of the original, that is the parameter to this object. Will make sure that the argument actually has the same real class as this object. It shouldn't be possible to initialize an object with something totally different.

Parameters
context:ThreadContext

the thread context

orig:IRubyObject

the original

Returns:IRubyObject

a copy unless the same thing

Annotations
@JRubyMethod
name:initialize_copy
visibility:PRIVATE
leftback to summary
public static IRubyObject left(ThreadContext context, IRubyObject recv)
Annotations
@JRubyMethod
name:left
meta:true
visibility:PRIVATE
leftObjback to summary
public IRubyObject leftObj(ThreadContext context)
Annotations
@JRubyMethod
name:left
visibility:PRIVATE
marshal_dumpback to summary
public IRubyObject marshal_dump(ThreadContext context)
Annotations
@JRubyMethod
name:marshal_dump
marshal_loadback to summary
public IRubyObject marshal_load(ThreadContext context, IRubyObject arg)
Annotations
@JRubyMethod
newRandomback to summary
public static RubyRandom newRandom(Ruby runtime, RubyClass randomClass, IRubyObject seed)

Deprecated

since 10.0.

Annotations
@Deprecated
since:10.0
newRandomback to summary
public static RubyRandom newRandom(ThreadContext context, RubyClass randomClass, IRubyObject seed)
newSeedback to summary
public static IRubyObject newSeed(ThreadContext context, IRubyObject recv)
Annotations
@JRubyMethod
name:new_seed
meta:true
op_equalback to summary
public IRubyObject op_equal(ThreadContext context, IRubyObject obj)

Overrides org.jruby.RubyBasicObject.op_equal.

Implements org.jruby.runtime.builtin.IRubyObject.op_equal.

Doc from org.jruby.RubyBasicObject.op_equal.

rb_obj_equal Will by default use identity equality to compare objects. This follows the Ruby semantics. The name of this method doesn't follow the convention because hierarchy problems

Annotations
@Override
@JRubyMethod
name:==
randback to summary
public static IRubyObject rand(ThreadContext context, IRubyObject recv, IRubyObject[] args)

Deprecated

Annotations
@Deprecated
randDefaultback to summary
public static IRubyObject randDefault(ThreadContext context, IRubyObject recv)

Hides org.jruby.RubyRandomBase.randDefault.

Annotations
@JRubyMethod
name:rand
meta:true
randDefaultback to summary
public static IRubyObject randDefault(ThreadContext context, IRubyObject recv, IRubyObject arg)

Hides org.jruby.RubyRandomBase.randDefault.

Annotations
@JRubyMethod
name:rand
meta:true
randKernelback to summary
pack-priv static IRubyObject randKernel(ThreadContext context, IRubyObject self, IRubyObject arg)
randKernelback to summary
pack-priv static IRubyObject randKernel(ThreadContext context, IRubyObject[] args)

Deprecated

Annotations
@Deprecated
randObjback to summary
public IRubyObject randObj(ThreadContext context, IRubyObject[] args)

Deprecated

Annotations
@Deprecated
randomSeedback to summary
public static RubyBignum randomSeed(Ruby runtime)
randomSeedBigIntegerback to summary
public static BigInteger randomSeedBigInteger(Random random)
rbDefaultback to summary
public static IRubyObject rbDefault(ThreadContext context, IRubyObject self)
Annotations
@JRubyMethod
name:default
meta:true
seedback to summary
public static IRubyObject seed(ThreadContext context, IRubyObject self)
Annotations
@JRubyMethod
meta:true
srandback to summary
public static IRubyObject srand(ThreadContext context, IRubyObject recv)
Annotations
@JRubyMethod
meta:true
srandback to summary
public static IRubyObject srand(ThreadContext context, IRubyObject recv, IRubyObject seed)
Annotations
@JRubyMethod
meta:true
srandCommonback to summary
public static IRubyObject srandCommon(ThreadContext context, IRubyObject recv)
srandCommonback to summary
public static IRubyObject srandCommon(ThreadContext context, IRubyObject recv, IRubyObject newSeed)
stateback to summary
public static IRubyObject state(ThreadContext context, IRubyObject recv)
Annotations
@JRubyMethod
name:state
meta:true
visibility:PRIVATE
stateObjback to summary
public IRubyObject stateObj(ThreadContext context)
Annotations
@JRubyMethod
name:state
visibility:PRIVATE
urandomback to summary
public static IRubyObject urandom(ThreadContext context, IRubyObject recv, IRubyObject num)
Annotations
@JRubyMethod
name:urandom
meta:true
org.jruby back to summary

public Class RubyRandom.RandomFormatter

extends Object
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static IRubyObject
public static IRubyObject
pack-priv static RubyRandom.RandomType
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

RandomFormatterback to summary
public RandomFormatter()

Method Detail

randomNumberback to summary
public static IRubyObject randomNumber(ThreadContext context, IRubyObject self)
Annotations
@JRubyMethod
name:rand, random_number
randomNumberback to summary
public static IRubyObject randomNumber(ThreadContext context, IRubyObject self, IRubyObject arg0)
Annotations
@JRubyMethod
name:rand, random_number
tryGetRndback to summary
pack-priv static RubyRandom.RandomType tryGetRnd(ThreadContext context, IRubyObject obj)
org.jruby back to summary

pack-priv final Class RubyRandom.RandomType

extends Object
Class Inheritance

Internal API, subject to change.

Field Summary

Modifier and TypeField and Description
pack-priv final Random
pack-priv final RubyInteger

Constructor Summary

AccessConstructor and Description
pack-priv
RandomType(IRubyObject seed)
Deprecated since 10.0.

pack-priv
pack-priv
RandomType(IRubyObject vseed, RubyBignum state, int left)
Deprecated since 10.0.

pack-priv
RandomType(ThreadContext context, IRubyObject vseed, RubyBignum state, int left)

pack-priv

Method Summary

Modifier and TypeMethod and Description
private static int[]
bigEndianToInts(byte[] buf, int initKeyLen)

public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

pack-priv int
pack-priv double
pack-priv double
genrandReal(boolean excl)

pack-priv double
pack-priv int
pack-priv RubyInteger
pack-priv RubyBignum
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public static Random
public static Random
public static Random
public static Random
randomFromLong(long seed)

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

implback to summary
pack-priv final Random impl
seedback to summary
pack-priv final RubyInteger seed

Constructor Detail

RandomTypeback to summary
pack-priv RandomType(IRubyObject seed)

Deprecated

since 10.0.

Annotations
@Deprecated
since:10.0
RandomTypeback to summary
pack-priv RandomType(ThreadContext context, IRubyObject seed)
RandomTypeback to summary
pack-priv RandomType(IRubyObject vseed, RubyBignum state, int left)

Deprecated

since 10.0.

Annotations
@Deprecated
since:10.0
RandomTypeback to summary
pack-priv RandomType(ThreadContext context, IRubyObject vseed, RubyBignum state, int left)
RandomTypeback to summary
pack-priv RandomType(RubyRandom.RandomType orig)

Method Detail

bigEndianToIntsback to summary
private static int[] bigEndianToInts(byte[] buf, int initKeyLen)
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
genrandInt32back to summary
pack-priv int genrandInt32()
genrandRealback to summary
pack-priv double genrandReal()
genrandRealback to summary
pack-priv double genrandReal(boolean excl)
genrandReal2back to summary
pack-priv double genrandReal2()
getLeftback to summary
pack-priv int getLeft()
getSeedback to summary
pack-priv RubyInteger getSeed()
getStateback to summary
pack-priv RubyBignum getState()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
randomFromBigIntegerback to summary
public static Random randomFromBigInteger(BigInteger big)
randomFromBignumback to summary
public static Random randomFromBignum(RubyBignum seed)
randomFromFixnumback to summary
public static Random randomFromFixnum(RubyFixnum seed)
randomFromLongback to summary
public static Random randomFromLong(long seed)