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.

  • 1.even? # => false
  • 1.odd? # => true
  • 2.even? # => true
  • 2.odd? # => false

Methods

even?   multiple_of?   odd?  

Public Instance methods

[Source]

    # File vendor/rails/activesupport/lib/active_support/core_ext/integer/even_odd.rb, line 14
14:         def even?
15:           multiple_of? 2
16:         end

[Source]

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

[Source]

    # File vendor/rails/activesupport/lib/active_support/core_ext/integer/even_odd.rb, line 18
18:         def odd?
19:           !even?
20:         end

[Validate]