解决方法
这并不完全符合您的问题,但它不会在Ruby中运行,但如果您在Rails中,则可以使用ordinalize将1转换为1,2到2等等.
例:
1.ordinalize # => "1st" 2.ordinalize # => "2nd" 3.ordinalize # => "3rd" ... 9.ordinalize # => "9th" ... 1000.ordinalize # => "1000th"
如果你想要大量的逗号:
number_with_delimiter(1000,:delimiter => ',') + 1000.ordinal # => "1,000th"