Class: Float

Inherits:
Object
  • Object
show all
Defined in:
lib/motel/common.rb

Overview

provide floating point rounding mechanism

Instance Method Summary collapse

Instance Method Details

#round_to(precision) ⇒ Object



74
75
76
77
# File 'lib/motel/common.rb', line 74

def round_to(precision)
   return nil if precision <= 0
   return (self * 10 ** precision).round.to_f / (10 ** precision)
end