D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Random
/
Formatter
/
Filename :
cdesc-Formatter.ri
back
Copy
U:RDoc::NormalModule[iI"Formatter:ETI"Random::Formatter;T0o:RDoc::Markup::Document:@parts[o;;[S:RDoc::Markup::Heading: leveli: textI"\Random number formatter.;To:RDoc::Markup::BlankLine o:RDoc::Markup::Paragraph;[I"XFormats generated random numbers in many manners. When <tt>'random/formatter'</tt> ;TI"]is required, several methods are added to empty core module <tt>Random::Formatter</tt>, ;TI"Cmaking them available as Random's instance and module methods.;T@o; ;[I"UStandard library SecureRandom is also extended with the module, and the methods ;TI"=described below are available as a module methods in it.;T@S; ; i;I" Examples;T@o; ;[I")Generate random hexadecimal strings:;T@o:RDoc::Markup::Verbatim;[ I" require 'random/formatter' ;TI" ;TI"prng = Random.new ;TI"-prng.hex(10) #=> "52750b30ffbc7de3b362" ;TI"-prng.hex(10) #=> "92b15d6c8dc4beb5f559" ;TI"3prng.hex(13) #=> "39b290146bea6ce975c37cfc23" ;TI"# or just ;TI"7Random.hex #=> "1aed0c631e41be7f77365415541052ee" ;T:@format0o; ;[I"$Generate random base64 strings:;T@o;;[ I",prng.base64(10) #=> "EcmTPZwWRAozdA==" ;TI",prng.base64(10) #=> "KO1nIU+p9DKxGg==" ;TI",prng.base64(12) #=> "7kJSM/MzBJI+75j8" ;TI"%Random.base64(4) #=> "bsQ3fQ==" ;T;0o; ;[I"$Generate random binary strings:;T@o;;[I"9prng.random_bytes(10) #=> "\016\t{\370g\310pbr\301" ;TI"?prng.random_bytes(10) #=> "\323U\030TO\234\357\020\a\337" ;TI"2Random.random_bytes(6) #=> "\xA1\xE6Lr\xC43" ;T;0o; ;[I"#Generate alphanumeric strings:;T@o;;[I",prng.alphanumeric(10) #=> "S8baxMJnPl" ;TI",prng.alphanumeric(10) #=> "aOxAg8BAJe" ;TI"0Random.alphanumeric #=> "TmP9OsJHJLtaZYhP" ;T;0o; ;[I"Generate UUIDs:;T@o;;[I":prng.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594" ;TI":prng.uuid #=> "bad85eb9-0713-4da7-8d36-07a8e4b00eab" ;TI"<Random.uuid #=> "f14e0271-de96-45cc-8911-8910292a42cd" ;T;0o; ;[I"IAll methods are available in the standard library SecureRandom, too:;T@o;;[I"<SecureRandom.hex #=> "05b45376a30c67238eb93b16499e50cf";T;0: @fileI"lib/random/formatter.rb;T:0@omit_headings_from_table_of_contents_below0o;;[o; ;[I"?Generate a random number in the given range as Random does;T@o;;[I"5prng.random_number #=> 0.5816771641321361 ;TI"&prng.random_number(1000) #=> 485 ;TI"$prng.random_number(1..6) #=> 3 ;TI"5prng.rand #=> 0.5816771641321361 ;TI"&prng.rand(1000) #=> 485 ;TI"#prng.rand(1..6) #=> 3;T;0;I" random.c;T;0;0;0[ [U:RDoc::Constant[i I"ALPHANUMERIC;TI"$Random::Formatter::ALPHANUMERIC;T:public0o;;[o; ;[I"2The default character list for #alphanumeric.;T;@O;0@O@cRDoc::NormalModule0[ [[I" class;T[[;[ [:protected[ [:private[ [I" instance;T[[;[[I"alphanumeric;TI"lib/random/formatter.rb;T[I"base64;T@|[I"hex;T@|[I" rand;TI" random.c;T[I"random_bytes;T@|[I"random_number;T@~[I"urlsafe_base64;T@|[I" uuid;T@|[I"uuid_v4;T@|[I"uuid_v7;T@|[;[ [;[[I"choose;T@|[I"gen_random;T@|[ [U:RDoc::Context::Section[i 0o;;[ ;0;0[@O@]I"Random;TcRDoc::NormalClass