aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/integer/even_odd.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/core_ext/integer/even_odd.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/integer/even_odd.rb39
1 files changed, 13 insertions, 26 deletions
diff --git a/activesupport/lib/active_support/core_ext/integer/even_odd.rb b/activesupport/lib/active_support/core_ext/integer/even_odd.rb
index b1d1e28062..6d005268a3 100644
--- a/activesupport/lib/active_support/core_ext/integer/even_odd.rb
+++ b/activesupport/lib/active_support/core_ext/integer/even_odd.rb
@@ -1,29 +1,16 @@
-module ActiveSupport #:nodoc:
- module CoreExtensions #:nodoc:
- module Integer #:nodoc:
- # 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
- module EvenOdd
- def multiple_of?(number)
- self % number == 0
- end
+class Integer
+ # Check whether the integer is evenly divisible by the argument.
+ def multiple_of?(number)
+ self % number == 0
+ end
- def even?
- multiple_of? 2
- end if RUBY_VERSION < '1.9'
+ # Is the integer a multiple of 2?
+ def even?
+ multiple_of? 2
+ end if RUBY_VERSION < '1.9'
- def odd?
- !even?
- end if RUBY_VERSION < '1.9'
- end
- end
- end
+ # Is the integer not a multiple of 2?
+ def odd?
+ !even?
+ end if RUBY_VERSION < '1.9'
end