Permalink
Browse files

Merge pull request #457 from vijaydev/master

Adds examples in code for ordinalizing negative numbers
  • Loading branch information...
2 parents a8daea4 + 91c1855 commit b3791da0318eb68f14a2d8d7658cc882784e6f6a @josevalim josevalim committed May 8, 2011
Showing with 3 additions and 1 deletion.
  1. +3 −1 activesupport/lib/active_support/inflector/methods.rb
@@ -135,6 +135,8 @@ def constantize(camel_cased_word) #:nodoc:
# 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 @@ def ordinalize(number)
end
end
end
-end
+end

0 comments on commit b3791da

Please sign in to comment.