Skip to content
This repository
Browse code

Document Integer#ordinal available in PR #2072.

Also remove an unasserted line in the tests.
  • Loading branch information...
commit a470d796972749889a27e2070bbd95346bba45ea 1 parent 6fa0190
Vijay Dev authored February 04, 2012
2  activesupport/CHANGELOG.md
Source Rendered
... ...
@@ -1,5 +1,7 @@
1 1
 ## Rails 4.0.0 (unreleased) ##
2 2
 
  3
+*    Adds Integer#ordinal to get the ordinal suffix string of an integer. *Tim Gildea*
  4
+
3 5
 *    AS::Callbacks: `:per_key` option is no longer supported
4 6
 
5 7
 *    `AS::Callbacks#define_callbacks`: add `:skip_after_callbacks_if_terminated` option.
1  activesupport/test/core_ext/integer_ext_test.rb
@@ -26,6 +26,5 @@ def test_ordinalize
26 26
   def test_ordinal
27 27
     assert_equal 'st', 1.ordinal
28 28
     assert_equal 'th', 8.ordinal
29  
-    1000000000000000000000000000000000000000000000000000000000000000000000.ordinal
30 29
   end
31 30
 end
17  railties/guides/source/active_support_core_extensions.textile
Source Rendered
@@ -1872,9 +1872,24 @@ The method +multiple_of?+ tests whether an integer is multiple of the argument:
1872 1872
 
1873 1873
 NOTE: Defined in +active_support/core_ext/integer/multiple.rb+.
1874 1874
 
  1875
+h4. +ordinal+
  1876
+
  1877
+The method +ordinal+ returns the ordinal suffix string corresponding to the receiver integer:
  1878
+
  1879
+<ruby>
  1880
+1.ordinal    # => "st"
  1881
+2.ordinal    # => "nd"
  1882
+53.ordinal   # => "rd"
  1883
+2009.ordinal # => "th"
  1884
+-21.ordinal  # => "st"
  1885
+-134.ordinal # => "th"
  1886
+</ruby>
  1887
+
  1888
+NOTE: Defined in +active_support/core_ext/integer/inflections.rb+.
  1889
+
1875 1890
 h4. +ordinalize+
1876 1891
 
1877  
-The method +ordinalize+ returns the ordinal string corresponding to the receiver integer:
  1892
+The method +ordinalize+ returns the ordinal string corresponding to the receiver integer. In comparison, note that the +ordinal+ method returns *only* the suffix string.
1878 1893
 
1879 1894
 <ruby>
1880 1895
 1.ordinalize    # => "1st"

0 notes on commit a470d79

Please sign in to comment.
Something went wrong with that request. Please try again.