Handling cases when , used instead of . more elegantly
This commit is contained in:
parent
ef6f54d966
commit
e8d7af9896
3 changed files with 18 additions and 1 deletions
|
@ -79,7 +79,7 @@ module CouchRest
|
|||
# Match numeric string
|
||||
def typecast_to_numeric(value, method)
|
||||
if value.respond_to?(:to_str)
|
||||
if value.to_str =~ /\A(-?(?:0|[1-9]\d*)(?:\.\d+)?|(?:\.\d+))\z/
|
||||
if value.gsub(/,/, '.').gsub(/\.(?!\d*\Z)/, '').to_str =~ /\A(-?(?:0|[1-9]\d*)(?:\.\d+)?|(?:\.\d+))\z/
|
||||
$1.send(method)
|
||||
else
|
||||
value
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue