def round_to_significant_digit(i, significant_digits = 1)
exp = Math.log10(i).floor - (significant_digits - 1)
(i / 10.0 ** exp).round * 10 ** exp
end
>> [230957, 83487, 4785].collect{|i|round_to_significant_digit(i)}
=> [200000, 80000, 5000]
И для дополнительного кредита:
>> [230957, 83487, 4785].collect{|i|round_to_significant_digit(i, 2)}
=> [230000, 83000, 4800]
>> [230957, 83487, 4785].collect{|i|round_to_significant_digit(i, 3)}
=> [231000, 83500, 4790]