aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/integer/multiple.rb
blob: e7606662d3533695902d672a3f57e4973fc886ba (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
# frozen_string_literal: true

class Integer
  # Check whether the integer is evenly divisible by the argument.
  #
  #   0.multiple_of?(0)  # => true
  #   6.multiple_of?(5)  # => false
  #   10.multiple_of?(2) # => true
  def multiple_of?(number)
    number != 0 ? self % number == 0 : zero?
  end
end