Skip to content

Commit

Permalink
Integer#even? and Integer#odd? are not needed for Ruby >= 1.8.7
Browse files Browse the repository at this point in the history
  • Loading branch information
fxn committed Nov 9, 2009
1 parent b6598c6 commit 329e7f4
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 37 deletions.
2 changes: 0 additions & 2 deletions activerecord/lib/active_record/validations.rb
@@ -1,5 +1,3 @@
require 'active_support/core_ext/integer/even_odd'

module ActiveRecord
# Raised by <tt>save!</tt> and <tt>create!</tt> when the record is invalid. Use the
# +record+ method to retrieve the record which did not validate.
Expand Down
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/core_ext/integer.rb
@@ -1,3 +1,3 @@
require 'active_support/core_ext/integer/even_odd'
require 'active_support/core_ext/integer/multiple'
require 'active_support/core_ext/integer/inflections'
require 'active_support/core_ext/integer/time'
16 changes: 0 additions & 16 deletions activesupport/lib/active_support/core_ext/integer/even_odd.rb

This file was deleted.

6 changes: 6 additions & 0 deletions activesupport/lib/active_support/core_ext/integer/multiple.rb
@@ -0,0 +1,6 @@
class Integer
# Check whether the integer is evenly divisible by the argument.
def multiple_of?(number)
self % number == 0
end
end
2 changes: 0 additions & 2 deletions activesupport/lib/active_support/ruby/shim.rb
Expand Up @@ -4,7 +4,6 @@
# Date next_year, next_month
# DateTime to_date, to_datetime, xmlschema
# Enumerable group_by, each_with_object, none?
# Integer even?, odd?
# Process Process.daemon
# REXML security fix
# String ord
Expand All @@ -13,7 +12,6 @@
require 'active_support/core_ext/date/calculations'
require 'active_support/core_ext/date_time/conversions'
require 'active_support/core_ext/enumerable'
require 'active_support/core_ext/integer/even_odd'
require 'active_support/core_ext/process/daemon'
require 'active_support/core_ext/string/conversions'
require 'active_support/core_ext/rexml'
Expand Down
16 changes: 0 additions & 16 deletions activesupport/test/core_ext/integer_ext_test.rb
Expand Up @@ -2,22 +2,6 @@
require 'active_support/core_ext/integer'

class IntegerExtTest < Test::Unit::TestCase
def test_even
assert [ -2, 0, 2, 4 ].all? { |i| i.even? }
assert ![ -1, 1, 3 ].all? { |i| i.even? }

assert 22953686867719691230002707821868552601124472329079.odd?
assert !22953686867719691230002707821868552601124472329079.even?
assert 22953686867719691230002707821868552601124472329080.even?
assert !22953686867719691230002707821868552601124472329080.odd?
end

def test_odd
assert ![ -2, 0, 2, 4 ].all? { |i| i.odd? }
assert [ -1, 1, 3 ].all? { |i| i.odd? }
assert 1000000000000000000000000000000000000000000000000000000001.odd?
end

def test_multiple_of
[ -7, 0, 7, 14 ].each { |i| assert i.multiple_of?(7) }
[ -7, 7, 14 ].each { |i| assert ! i.multiple_of?(6) }
Expand Down

0 comments on commit 329e7f4

Please sign in to comment.