Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Float.class_eval do
- alias_method :original_round, :round
- def round(decs = 0)
- if decs == 0
- self.original_round
- elsif decs > 0
- decs = decs.to_i
- (self * 10 ** decs).original_round.to_f / 10 ** decs
- else
- raise ArgumentError, "You can't pass negative arguments"
- end
- end
- end
Add Comment
Please, Sign In to add comment