aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext
diff options
context:
space:
mode:
authorTim Gildea <tgildea@gmail.com>2011-07-14 11:16:28 -0400
committerVijay Dev <vijaydev.cse@gmail.com>2012-02-04 18:25:54 +0530
commit6fa0190fe4c1bf9f8306198536306de883039a27 (patch)
treeb3d7f929a65a0806d69b0605711691d71ceb71c6 /activesupport/lib/active_support/core_ext
parent7a72fdc7dcbb58a58b67944f8c1dfeae5cb6ed23 (diff)
downloadrails-6fa0190fe4c1bf9f8306198536306de883039a27.tar.gz
rails-6fa0190fe4c1bf9f8306198536306de883039a27.tar.bz2
rails-6fa0190fe4c1bf9f8306198536306de883039a27.zip
Add ActiveSupport::Inflector.ordinal and Integer#ordinal
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r--activesupport/lib/active_support/core_ext/integer/inflections.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/integer/inflections.rb b/activesupport/lib/active_support/core_ext/integer/inflections.rb
index 0e606056c0..1e30687166 100644
--- a/activesupport/lib/active_support/core_ext/integer/inflections.rb
+++ b/activesupport/lib/active_support/core_ext/integer/inflections.rb
@@ -14,4 +14,18 @@ class Integer
def ordinalize
ActiveSupport::Inflector.ordinalize(self)
end
+
+ # Ordinal returns the suffix used to denote the position
+ # in an ordered sequence such as 1st, 2nd, 3rd, 4th.
+ #
+ # 1.ordinal # => "st"
+ # 2.ordinal # => "nd"
+ # 1002.ordinal # => "nd"
+ # 1003.ordinal # => "rd"
+ # -11.ordinal # => "th"
+ # -1001.ordinal # => "st"
+ #
+ def ordinal
+ ActiveSupport::Inflector.ordinal(self)
+ end
end