File tree Expand file tree Collapse file tree 5 files changed +18
-4
lines changed Expand file tree Collapse file tree 5 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ class ColorMaker
6464 end
6565
6666 def make_alpha_color (multiplier )
67- rand = Random :: DEFAULT .next_int
67+ rand = Random .next_int
6868 r = ((rand >> 16 ) % 256 ).to_i
6969 g = ((rand >> 8 ) % 256 ).to_i
7070 b = (rand % 256 ).to_i
Original file line number Diff line number Diff line change @@ -196,7 +196,11 @@ describe "Random" do
196196 end
197197
198198 it " gets a random bool" do
199- Random ::DEFAULT .next_bool.should be_a(Bool )
199+ Random .next_bool.should be_a(Bool )
200+ end
201+
202+ it " gets a random int" do
203+ Random .next_int.should be_a(Int32 )
200204 end
201205
202206 it " generates by accumulation" do
Original file line number Diff line number Diff line change 9191# ```
9292# require "colorize"
9393#
94- # "foo".colorize(Random::DEFAULT .next_bool ? :green : :default)
94+ # "foo".colorize(Random.next_bool ? :green : :default)
9595# ```
9696#
9797# Available colors are:
Original file line number Diff line number Diff line change @@ -136,7 +136,7 @@ class HTTP::WebSocket::Protocol
136136 private def write_payload (data )
137137 return @io .write(data) unless @masked
138138
139- key = Random :: DEFAULT .next_int
139+ key = Random .next_int
140140 mask_array = key.unsafe_as(StaticArray (UInt8 , 4 ))
141141 @io .write mask_array.to_slice
142142
Original file line number Diff line number Diff line change @@ -426,6 +426,16 @@ module Random
426426 random_bytes(n).hexstring
427427 end
428428
429+ # See `#next_bool`.
430+ def self.next_bool : Bool
431+ DEFAULT .next_bool
432+ end
433+
434+ # See `#next_int`.
435+ def self.next_int : Int32
436+ DEFAULT .next_int
437+ end
438+
429439 # See `#rand`.
430440 def self.rand : Float64
431441 DEFAULT .rand
You can’t perform that action at this time.
0 commit comments