Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adds code examples for negative ordinalize

  • Loading branch information...
commit 91c18554f6f54ae2d4cb7e945d830b75aa0c3b18 1 parent a8daea4
@vijaydev vijaydev authored
Showing with 3 additions and 1 deletion.
  1. +3 −1 activesupport/lib/active_support/inflector/methods.rb
View
4 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
Please sign in to comment.
Something went wrong with that request. Please try again.