Module ActiveSupport::CoreExtensions::Integer::EvenOdd
In: vendor/rails/activesupport/lib/active_support/core_ext/integer/even_odd.rb

For checking if a fixnum is even or odd.

  2.even?  # => true
  2.odd?   # => false
  1.even?  # => false
  1.odd?   # => true
  0.even?  # => true
  0.odd?   # => false
  -1.even? # => false
  -1.odd?  # => true

Methods

even?   multiple_of?   odd?  

Public Instance methods

[Source]

    # File vendor/rails/activesupport/lib/active_support/core_ext/integer/even_odd.rb, line 19
19:         def even?
20:           multiple_of? 2
21:         end

[Source]

    # File vendor/rails/activesupport/lib/active_support/core_ext/integer/even_odd.rb, line 15
15:         def multiple_of?(number)
16:           self % number == 0
17:         end

[Source]

    # File vendor/rails/activesupport/lib/active_support/core_ext/integer/even_odd.rb, line 23
23:         def odd?
24:           !even?
25:         end

[Validate]