Class/Module Index [+]

Quicksearch

ActiveSupport::CoreExtensions::Integer::EvenOdd

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

Public Instance Methods

even?() click to toggle source
# File lib/active_support/core_ext/integer/even_odd.rb, line 19
def even?
  multiple_of? 2
end
multiple_of?(number) click to toggle source
# File lib/active_support/core_ext/integer/even_odd.rb, line 15
def multiple_of?(number)
  self % number == 0
end
odd?() click to toggle source
# File lib/active_support/core_ext/integer/even_odd.rb, line 23
def odd?
  !even?
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.