aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/inflector.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/inflector.rb')
-rw-r--r--activesupport/lib/active_support/inflector.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/inflector.rb b/activesupport/lib/active_support/inflector.rb
index 88f56403c8..be25a93687 100644
--- a/activesupport/lib/active_support/inflector.rb
+++ b/activesupport/lib/active_support/inflector.rb
@@ -60,6 +60,19 @@ module Inflector
end
end
+ def ordinalize(number)
+ if (11..13).include?(number.to_i % 100)
+ "#{number}th"
+ else
+ case number.to_i % 10
+ when 1: "#{number}st"
+ when 2: "#{number}nd"
+ when 3: "#{number}rd"
+ else "#{number}th"
+ end
+ end
+ end
+
private
def uncountable_words #:doc
%w( equipment information rice money species series fish )
@@ -121,4 +134,4 @@ module Inflector
[/s$/i, '']
]
end
-end \ No newline at end of file
+end