X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/9d2fed811fd37577bf5cce8e8fe03d2097852428..f03c8637f7377f34d31f4b0bd88caa4a9e7a9570:/lib/osm.rb?ds=sidebyside 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'