daily pastebin goal
29%
SHARE
TWEET

Untitled

a guest Jul 12th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Float.class_eval do
  2.   alias_method :original_round, :round
  3.   def round(decs = 0)
  4.     if decs == 0
  5.       self.original_round
  6.     elsif decs > 0
  7.       decs = decs.to_i
  8.       (self * 10 ** decs).original_round.to_f / 10 ** decs
  9.     else
  10.       raise ArgumentError, "You can't pass negative arguments"
  11.     end
  12.   end
  13. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top