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:
Javi Martín
2018-10-01 20:44:08 +02:00
parent ba7ca11cd8
commit 6f62d76c71
2 changed files with 14 additions and 6 deletions

View File

@@ -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