Method: Quantify::Quantity#round!

Defined in:
lib/quantify/quantity.rb

#round!(decimal_places = 0) ⇒ Object

Round the value attribute to the specified number of decimal places. If no argument is given, the value is rounded to NO decimal places, i.e. to an integer



277
278
279
280
281
# File 'lib/quantify/quantity.rb', line 277

def round!(decimal_places=0)
  factor = ( decimal_places == 0 ? 1 : 10.0 ** decimal_places )
  @value = (@value * factor).round / factor
  self
end