X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/d74d4f8d195673250c3f2e841d28f185d74d8849..22d6633114d02af0e543afbb23cc05e33d1a1c9d:/lib/osm.rb diff --git a/lib/osm.rb b/lib/osm.rb index d4c13ad7f..4a6237b12 100644 --- a/lib/osm.rb +++ b/lib/osm.rb @@ -550,6 +550,13 @@ module OSM return nil end + # Parse a float, raising a specified exception on failure + def self.parse_float(str, klass, *args) + Float(str) + rescue + raise klass.new(*args) + end + # Construct a random token of a given length def self.make_token(length = 30) chars = 'abcdefghijklmnopqrtuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'