Simplify random seed conversion to float
The method `to_f` already returns `0.0` instead of raising an exception when handling non-numeric values.
This commit is contained in:
@@ -117,12 +117,7 @@ class Legislation::ProcessesController < Legislation::BaseController
|
||||
end
|
||||
|
||||
def set_random_seed
|
||||
seed = begin
|
||||
Float(params[:random_seed] || session[:random_seed] || (rand(99) / 100.0))
|
||||
rescue
|
||||
0
|
||||
end
|
||||
|
||||
seed = (params[:random_seed] || session[:random_seed] || (rand(99) / 100.0)).to_f
|
||||
session[:random_seed] = seed
|
||||
params[:random_seed] = seed
|
||||
seed = (-1..1).cover?(seed) ? seed : 1
|
||||
|
||||
Reference in New Issue
Block a user