From 91c18554f6f54ae2d4cb7e945d830b75aa0c3b18 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sun, 8 May 2011 23:48:15 +0530 Subject: adds code examples for negative ordinalize --- activesupport/lib/active_support/inflector/methods.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb index dd2beef89d..a2c4f7bfda 100644 --- a/activesupport/lib/active_support/inflector/methods.rb +++ b/activesupport/lib/active_support/inflector/methods.rb @@ -135,6 +135,8 @@ module ActiveSupport # ordinalize(2) # => "2nd" # ordinalize(1002) # => "1002nd" # ordinalize(1003) # => "1003rd" + # ordinalize(-11) # => "-11th" + # ordinalize(-1021) # => "-1021st" def ordinalize(number) if (11..13).include?(number.to_i.abs % 100) "#{number}th" @@ -148,4 +150,4 @@ module ActiveSupport end end end -end \ No newline at end of file +end -- cgit v1.2.3