Created
August 22, 2017 16:33
-
-
Save gregawoods/62ca361661ca77272fd2c5422b02736f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# When inspecting a BigDecimal in the console, default to | |
# printing it as a float. This is purely cosmetetic and | |
# is easier to read compared to scientific notation. | |
# | |
# Before: | |
# [1] pry(main)> d = BigDecimal.new(10) | |
# => 0.1e2 | |
# | |
# After: | |
# [1] pry(main)> d = BigDecimal.new(10) | |
# => 10.0 | |
# | |
module BigDecimalInspectFloat | |
def inspect | |
to_s('F') | |
end | |
end | |
BigDecimal.send(:prepend, BigDecimalInspectFloat) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment