使用
Float#round
带有否定论点:
316.28.round(-2)
#â 300
363.13.round(-2)
#â 400
input = _
#â [{:y=>316.28, :label=>"Kaimur", :color=>"Light_Green"},
# {:y=>323.63, :label=>"Banka", :color=>"Light_Green"},
# {:y=>327.85, :label=>"Gaya", :color=>"Light_Green"},
# {:y=>346.11, :label=>"EastChamparan", :color=>"Light_Green"},
# {:y=>358.38, :label=>"Nalanda", :color=>"Light_Green"},
# {:y=>363.13, :label=>"Madhubani", :color=>"Light_Green"}]
ys = input.map { |e| e[:y] }
#â [316.28, 323.63, 327.85, 346.11, 358.38, 363.13]
Range.new *[ys.min, ys.max].map { |e| e.round(-e.round.to_s.length+1) }
#â 300..400