bytes

prng.bytes(size) â a_string Instance Public methods Returns a random binary string containing size bytes. random_string = Random.new.bytes(10) # => "\xD7:R\xAB?\x83\xCE\xFAkO" random_string.size # => 10

rand 2

prng.rand â floatprng.rand(max) â number Instance Public methods When max is an Integer, rand returns a random integer greater than or equal to zero and less than max. Unlike Kernel#rand, when max is a negative integer or zero, rand raises an ArgumentError. prng = Random.new prng.rand(100) # => 42 When max is a Float, rand returns a random floating point number between 0.0 and max, including 0.0 and excluding max. prng.rand(1.5) # => 1.4600282860034115 When max

seed

prng.seed â integer Instance Public methods Returns the seed value used to initialize the generator. This may be used to initialize another generator with the same state at a later time, causing it to produce the same sequence of numbers. prng1 = Random.new(1234) prng1.seed #=> 1234 prng1.rand(100) #=> 47 prng2 = Random.new(prng1.seed) prng2.rand(100) #=> 47

json_create

json_create(object) Class Public methods Deserializes JSON string by constructing new Range object with arguments a serialized by to_json.

new

Range.new(begin, end, exclude_end=false) â rng Class Public methods Constructs a range using the given begin and end. If the exclude_end parameter is omitted or is false, the rng will include the end object; otherwise, it will be excluded.

==

rng == obj â true or false Instance Public methods Returns true only if obj is a Range, has equivalent begin and end items (by comparing them with ==), and has the same exclude_end? setting as the range. (0..2) == (0..2) #=> true (0..2) == Range.new(0,2) #=> true (0..2) == (0...2) #=> false

===

rng === obj â true or false Instance Public methods Returns true if obj is an element of the range, false otherwise. Conveniently, === is the comparison operator used by case statements. case 79 when 1..50 then print "low\n" when 51..75 then print "medium\n" when 76..100 then print "high\n" end produces: high

as_json

as_json(*) Instance Public methods Returns a hash, that will be turned into a JSON object and represent this object.

begin

rng.begin â obj Instance Public methods Returns the object that defines the beginning of the range. (1..10).begin #=> 1

bsearch

rng.bsearch {|obj| block } â value Instance Public methods By using binary search, finds a value in range which meets the given condition in O(log n) where n is the size of the range. You can use this method in two use cases: a find-minimum mode and a find-any mode. In either case, the elements of the range must be monotone (or sorted) with respect to the block. In find-minimum mode (this is a good choice for typical use case), the block must return true or false, and there must