Method: String#to_d

Defined in:
lib/ruby/jruby_hack.rb

#to_dBigDecimal

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.

Examples:

"1.0".to_d  #=> BigDecimal("1.0")

Returns:



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