aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-03-21 04:13:57 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-03-21 04:39:53 -0700
commit54cf0fc476b2d77adb8a124c27a79a048fa4ddb5 (patch)
treeef51d129ec8d0ff15507c61f97fdc32ab1d89633 /activesupport/lib
parentb4a1718832c70005e45a930d5106857cf882e147 (diff)
downloadrails-54cf0fc476b2d77adb8a124c27a79a048fa4ddb5.tar.gz
rails-54cf0fc476b2d77adb8a124c27a79a048fa4ddb5.tar.bz2
rails-54cf0fc476b2d77adb8a124c27a79a048fa4ddb5.zip
Convert integer extension modules to class reopens
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/integer.rb5
-rw-r--r--activesupport/lib/active_support/core_ext/integer/even_odd.rb39
-rw-r--r--activesupport/lib/active_support/core_ext/integer/inflections.rb26
3 files changed, 27 insertions, 43 deletions
diff --git a/activesupport/lib/active_support/core_ext/integer.rb b/activesupport/lib/active_support/core_ext/integer.rb
index dc332db3ba..538c0a2c8c 100644
--- a/activesupport/lib/active_support/core_ext/integer.rb
+++ b/activesupport/lib/active_support/core_ext/integer.rb
@@ -1,2 +1,5 @@
+require 'active_support/core_ext/integer/even_odd'
+require 'active_support/core_ext/integer/inflections'
+
require 'active_support/core_ext/util'
-ActiveSupport.core_ext Integer, %w(even_odd inflections time)
+ActiveSupport.core_ext Integer, %w(time)
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
diff --git a/activesupport/lib/active_support/core_ext/integer/inflections.rb b/activesupport/lib/active_support/core_ext/integer/inflections.rb
index 804702beb2..7a8c081b73 100644
--- a/activesupport/lib/active_support/core_ext/integer/inflections.rb
+++ b/activesupport/lib/active_support/core_ext/integer/inflections.rb
@@ -1,20 +1,14 @@
require 'active_support/inflector'
-module ActiveSupport #:nodoc:
- module CoreExtensions #:nodoc:
- module Integer #:nodoc:
- module Inflections
- # Ordinalize turns a number into an ordinal string used to denote the
- # position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
- #
- # 1.ordinalize # => "1st"
- # 2.ordinalize # => "2nd"
- # 1002.ordinalize # => "1002nd"
- # 1003.ordinalize # => "1003rd"
- def ordinalize
- Inflector.ordinalize(self)
- end
- end
- end
+class Integer
+ # Ordinalize turns a number into an ordinal string used to denote the
+ # position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
+ #
+ # 1.ordinalize # => "1st"
+ # 2.ordinalize # => "2nd"
+ # 1002.ordinalize # => "1002nd"
+ # 1003.ordinalize # => "1003rd"
+ def ordinalize
+ Inflector.ordinalize(self)
end
end