diff options
author | José Valim <jose.valim@gmail.com> | 2011-05-08 11:21:47 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-05-08 11:21:47 -0700 |
commit | b3791da0318eb68f14a2d8d7658cc882784e6f6a (patch) | |
tree | a0300719abdf225ec4c57f1fc90f9e7e1244f45f /activesupport | |
parent | a8daea4b85b2709600d5e894b7380149b0854b53 (diff) | |
parent | 91c18554f6f54ae2d4cb7e945d830b75aa0c3b18 (diff) | |
download | rails-b3791da0318eb68f14a2d8d7658cc882784e6f6a.tar.gz rails-b3791da0318eb68f14a2d8d7658cc882784e6f6a.tar.bz2 rails-b3791da0318eb68f14a2d8d7658cc882784e6f6a.zip |
Merge pull request #457 from vijaydev/master
Adds examples in code for ordinalizing negative numbers
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/inflector/methods.rb | 4 |
1 files changed, 3 insertions, 1 deletions
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 |