smalltalk
/
osmo-st-all
Archived
1
0
Fork 0
This repository has been archived on 2022-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
osmo-st-all/grease/Core/Text/GROrdinalizePrinter.st

25 lines
534 B
Smalltalk
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Eval [
'From PharoCore1.0rc1 of 19 October 2009 [Latest update: #10505] on 9 March 2010 at 6:38:04 pm'
]
GRPrinter subclass: GROrdinalizePrinter [
<comment: nil>
<category: 'Grease-Core-Text'>
print: anObject on: aStream [
<category: 'printing'>
aStream nextPutAll: (self ordinalize: anObject integerPart)
]
ordinalize: anInteger [
<category: 'private'>
^(anInteger \\ 100 between: 11 and: 13)
ifTrue: ['th']
ifFalse: [#('st' 'nd' 'rd') at: anInteger \\ 10 ifAbsent: ['th']]
]
]