Skip to content

Instantly share code, notes, and snippets.

@gregawoods
Created August 22, 2017 16:33
Show Gist options
  • Save gregawoods/62ca361661ca77272fd2c5422b02736f to your computer and use it in GitHub Desktop.
Save gregawoods/62ca361661ca77272fd2c5422b02736f to your computer and use it in GitHub Desktop.
# 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