Class: Integer

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

Overview

Module : quantize Purpose: Adds a quantize method to the Integer class Date : 17th August 2010 Author : B.James

Instance Method Summary collapse

Instance Method Details

#quantize(q) ⇒ Object



10
11
12
13
# File 'lib/quantize.rb', line 10

def quantize( q )
        # Rounds i to the nearest whole q. eg. q=10 i=14 rounds i to 10
        ((self/q) * q).round.to_i
end