Extract common code for parsing floats
This commit is contained in:
parent
9d2fed811f
commit
f03c8637f7
3 changed files with 11 additions and 20 deletions
|
@ -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'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue