Class: Float
- Inherits:
-
Object
- Object
- Float
- Defined in:
- lib/stat_sugar/numbers.rb
Instance Method Summary collapse
Instance Method Details
#approx_equal?(float, options = {}) ⇒ Boolean
17 18 19 20 |
# File 'lib/stat_sugar/numbers.rb', line 17 def approx_equal?(float, = {}) tolerance = [:with_tolerance] || 0.1 self == float || (float >= self - (self * tolerance) && float <= self + (self * tolerance)) end |
#pad(number, round = 20) ⇒ Object
12 13 14 15 |
# File 'lib/stat_sugar/numbers.rb', line 12 def pad(number,round = 20) num = self.round(round) "#{" " * (number - num.to_s.length)}#{num}" end |