Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. # When inspecting a BigDecimal in the console, default to
  2. # printing it as a float. This is purely cosmetetic and
  3. # is easier to read compared to scientific notation.
  4. #
  5. # Before:
  6. # [1] pry(main)> d = BigDecimal.new(10)
  7. # => 0.1e2
  8. #
  9. # After:
  10. # [1] pry(main)> d = BigDecimal.new(10)
  11. # => 10.0
  12. #
  13. module BigDecimalInspectFloat
  14. def inspect
  15. to_s('F')
  16. end
  17. end
  18. BigDecimal.send(:prepend, BigDecimalInspectFloat)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement