Sha256: 93d9aa606aedf1879efc9dfc71aceb3040b112e0695e45284e8823dc04a5eeb8

Contents?: true

Size: 386 Bytes

Versions: 6

Compression:

Stored size: 386 Bytes

Contents

#!/usr/bin/env ruby
# -*- encoding: utf-8 -*-
# Copyright Steffi Dorn <mail@muflax.com>, 2017
# License: GNU APGLv3 (or later) <http://www.gnu.org/copyleft/gpl.html>

class Numeric
  def round_into num
    ((self / num) / num + 1) * num
  end

  def round_to num
    (self / num.to_f).round * num
  end

  def multiple_of?(number)
    number != 0 ? self % number == 0 : zero?
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
muflax-0.3.5 lib/muflax/num.rb
muflax-0.3.4 lib/muflax/num.rb
muflax-0.3.3 lib/muflax/num.rb
muflax-0.3.2 lib/muflax/num.rb
muflax-0.3.1 lib/muflax/num.rb
muflax-0.3.0 lib/muflax/num.rb