X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/d74d4f8d195673250c3f2e841d28f185d74d8849..78e97ade45856647d77a2f4dc966a4eb301e3ad1:/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'