diff options
author | Xavier Noria <fxn@hashref.com> | 2012-02-07 14:08:02 -0800 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2012-02-07 14:08:02 -0800 |
commit | 827b520bd1f946471105d9dd9593b9db56b0f6bc (patch) | |
tree | ef9b079ea4af43a655aedec75201623f96f2621b /activesupport/lib/active_support/core_ext | |
parent | 55cc16f502399b69051e4ff5432569bbea45e9c0 (diff) | |
parent | a470d796972749889a27e2070bbd95346bba45ea (diff) | |
download | rails-827b520bd1f946471105d9dd9593b9db56b0f6bc.tar.gz rails-827b520bd1f946471105d9dd9593b9db56b0f6bc.tar.bz2 rails-827b520bd1f946471105d9dd9593b9db56b0f6bc.zip |
Merge pull request #4878 from vijaydev/ordinal-2072
PR #2072 with docs
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r-- | activesupport/lib/active_support/core_ext/integer/inflections.rb | 14 |
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 |