Class: Float

Inherits:
Object
  • Object
show all
Defined in:
lib/trak/core_ext/round_to_nearest.rb

Instance Method Summary collapse

Instance Method Details

#round_to_nearest(integer = 1) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/trak/core_ext/round_to_nearest.rb', line 12

def round_to_nearest(integer = 1)
  if integer == 1
    self.round
  else
    ((self / integer).round * integer).to_i
  end
end