Articles
|
News
|
Weblogs
|
Books
|
Forums
Artima Forums
|
Articles
|
Weblogs
|
Java Answers
|
News
Sponsored Link
•
Ruby Buzz Forum
English Ordinals in Ruby
0
replies on
1
page.
Welcome
Guest
Sign In
Back to Topic List
Reply to this Topic
Search Forum
Threaded View
Previous Topic
Next Topic
Flat View: This topic has
0
replies on
1
page
Duncan Beevers
Posts: 68
Nickname: dbeevers
Registered: May, 2008
Duncan Beevers is a hack and jester building shiny baubles from bytes and tears.
English Ordinals in Ruby
Posted: Nov 17, 2008 3:12 PM
Reply
This post originated from an RSS feed registered with Ruby Buzz by Duncan Beevers.
Original Post:
English Ordinals in Ruby
Feed Title: dweebd
Feed URL: http://www.dweebd.com/feed/
Feed Description: Ruby ejecta from the leading edge
Latest
Ruby Buzz
Posts
Latest Ruby Buzz Posts by
Duncan Beevers
Latest Posts From
dweebd
Advertisement
class Numeric def to_ordinal to_i.to_s + ((11..13) === (n = to_i.abs % 100) ? 'th' : { 1 => 'st', 2 => 'nd', 3 => 'rd' }.fetch(n % 10, 'th')) end end This code is based on a snippet for generating ordinals. The other examples used [...]
Read:
English Ordinals in Ruby
Previous Topic
Next Topic
Sponsored Links
Web
Artima.com
Copyright
© 1996-2019 Artima, Inc. All Rights Reserved. -
Privacy Policy
-
Terms of Use