]> git.openstreetmap.org Git - rails.git/blobdiff - lib/osm.rb
Standardize form width
[rails.git] / lib / osm.rb
index d4c13ad7feab520f97d1f207b46ac3e36ef3528a..4a6237b12b3dd8cd8c71fc8bf3f9ba5697dd97e7 100644 (file)
@@ -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'