提交 d5f8486d 编写于 作者: Y yuuji.yaginuma

Use BigDecimal provided methods to convert String to BigDecimal

`String#to_d` does not raise an exception if an invalid value is specified.
So can remove exception handling.

```
$ bundle exec ruby -v -rbigdecimal -rbigdecimal/util -e 'p "123,003".to_d'
ruby 2.6.0dev (2018-12-21 trunk 66474) [x86_64-linux]
0.123e3
```
上级 1ff22133
......@@ -68,11 +68,7 @@ def content_type
"float" => Proc.new { |float| float.to_f },
"decimal" => Proc.new do |number|
if String === number
begin
BigDecimal(number)
rescue ArgumentError
BigDecimal(number.to_f.to_s)
end
number.to_d
else
BigDecimal(number)
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册