Method: String#to_d
- Defined in:
- lib/ruby/jruby_hack.rb
#to_d ⇒ BigDecimal
Converts the string to a BigDecimal after validating the format. If the string does not match the pattern for a valid number, an ArgumentError is raised.
553 554 555 556 557 558 559 |
# File 'lib/ruby/jruby_hack.rb', line 553 def to_d if BIGDECIMAL =~ self BigDecimal(to_s) else raise ArgumentError, "#{inspect} is not a valid number" end end |