The Inbox: Kernel-ct.1342.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: Kernel-ct.1342.mcz

commits-2
A new version of Kernel was added to project The Inbox:
http://source.squeak.org/inbox/Kernel-ct.1342.mcz

==================== Summary ====================

Name: Kernel-ct.1342
Author: ct
Time: 25 September 2020, 6:32:44.665274 pm
UUID: 037ef8ee-228f-914b-8d1e-b05cac84772b
Ancestors: Kernel-eem.1341

Add ordinal suffix logic to Integer

Example:
        (1 to: 30) collect: [:ea | ea withOrdinalSuffix]

=============== Diff against Kernel-eem.1341 ===============

Item was added:
+ ----- Method: Integer>>ordinalSuffix (in category 'printing') -----
+ ordinalSuffix
+ "Answer a string containing the ordinal suffix of the receiver, e.g. 'th' for 4, or 'rd' for 23."
+
+ self \\ 100 // 10 = 1 ifFalse: [
+ self \\ 10
+ caseOf: {
+ [1] -> [^ 'st'].
+ [2] -> [^ 'nd'].
+ [3] -> [^ 'rd'] }
+ otherwise: []].
+ ^ 'th'!

Item was added:
+ ----- Method: Integer>>printWithOrdinalSuffixOn: (in category 'printing') -----
+ printWithOrdinalSuffixOn: aStream
+
+ aStream
+ print: self;
+ nextPutAll: self ordinalSuffix.!

Item was added:
+ ----- Method: Integer>>withOrdinalSuffix (in category 'printing') -----
+ withOrdinalSuffix
+
+ ^ String streamContents: [:stream |
+ self printWithOrdinalSuffixOn: stream]!


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Kernel-ct.1342.mcz

Jakob Reschke
I think that such things should not really belong in Kernel. Is there
another suitable package that can provide this as an extension method?

Also note that this is not internationalized yet (English only), but
judging by the selectors it might well be used to produce localized
output in the future. Maybe that could influence the selection of a
package.

Am Fr., 25. Sept. 2020 um 18:32 Uhr schrieb <[hidden email]>:

>
> A new version of Kernel was added to project The Inbox:
> http://source.squeak.org/inbox/Kernel-ct.1342.mcz
>
> ==================== Summary ====================
>
> Name: Kernel-ct.1342
> Author: ct
> Time: 25 September 2020, 6:32:44.665274 pm
> UUID: 037ef8ee-228f-914b-8d1e-b05cac84772b
> Ancestors: Kernel-eem.1341
>
> Add ordinal suffix logic to Integer
>
> Example:
>         (1 to: 30) collect: [:ea | ea withOrdinalSuffix]
>
> =============== Diff against Kernel-eem.1341 ===============
>
> Item was added:
> + ----- Method: Integer>>ordinalSuffix (in category 'printing') -----
> + ordinalSuffix
> +       "Answer a string containing the ordinal suffix of the receiver, e.g. 'th' for 4, or 'rd' for 23."
> +
> +       self \\ 100 // 10 = 1 ifFalse: [
> +               self \\ 10
> +                       caseOf: {
> +                               [1] -> [^ 'st'].
> +                               [2] -> [^ 'nd'].
> +                               [3] -> [^ 'rd'] }
> +                       otherwise: []].
> +       ^ 'th'!
>
> Item was added:
> + ----- Method: Integer>>printWithOrdinalSuffixOn: (in category 'printing') -----
> + printWithOrdinalSuffixOn: aStream
> +
> +       aStream
> +               print: self;
> +               nextPutAll: self ordinalSuffix.!
>
> Item was added:
> + ----- Method: Integer>>withOrdinalSuffix (in category 'printing') -----
> + withOrdinalSuffix
> +
> +       ^ String streamContents: [:stream |
> +               self printWithOrdinalSuffixOn: stream]!
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Kernel-ct.1342.mcz

Christoph Thiede

Hi Jakob,


there are also #asWords, #threeDigitName, or #asPluralBasedOn: which seem to operate on a similar level. Maybe we should move them all into an extension category of another package (System? Multilingual-Languages?)? I also agree it's not internationalized yet, but it does not feel the right time for me to design an international solution for this at the moment (I once tried out Squeak 5.3 with German language once, and it was horrible).


Best,

Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von Jakob Reschke <[hidden email]>
Gesendet: Freitag, 25. September 2020 18:36:57
An: [hidden email]
Betreff: Re: [squeak-dev] The Inbox: Kernel-ct.1342.mcz
 
I think that such things should not really belong in Kernel. Is there
another suitable package that can provide this as an extension method?

Also note that this is not internationalized yet (English only), but
judging by the selectors it might well be used to produce localized
output in the future. Maybe that could influence the selection of a
package.

Am Fr., 25. Sept. 2020 um 18:32 Uhr schrieb <[hidden email]>:
>
> A new version of Kernel was added to project The Inbox:
> http://source.squeak.org/inbox/Kernel-ct.1342.mcz
>
> ==================== Summary ====================
>
> Name: Kernel-ct.1342
> Author: ct
> Time: 25 September 2020, 6:32:44.665274 pm
> UUID: 037ef8ee-228f-914b-8d1e-b05cac84772b
> Ancestors: Kernel-eem.1341
>
> Add ordinal suffix logic to Integer
>
> Example:
>         (1 to: 30) collect: [:ea | ea withOrdinalSuffix]
>
> =============== Diff against Kernel-eem.1341 ===============
>
> Item was added:
> + ----- Method: Integer>>ordinalSuffix (in category 'printing') -----
> + ordinalSuffix
> +       "Answer a string containing the ordinal suffix of the receiver, e.g. 'th' for 4, or 'rd' for 23."
> +
> +       self \\ 100 // 10 = 1 ifFalse: [
> +               self \\ 10
> +                       caseOf: {
> +                               [1] -> [^ 'st'].
> +                               [2] -> [^ 'nd'].
> +                               [3] -> [^ 'rd'] }
> +                       otherwise: []].
> +       ^ 'th'!
>
> Item was added:
> + ----- Method: Integer>>printWithOrdinalSuffixOn: (in category 'printing') -----
> + printWithOrdinalSuffixOn: aStream
> +
> +       aStream
> +               print: self;
> +               nextPutAll: self ordinalSuffix.!
>
> Item was added:
> + ----- Method: Integer>>withOrdinalSuffix (in category 'printing') -----
> + withOrdinalSuffix
> +
> +       ^ String streamContents: [:stream |
> +               self printWithOrdinalSuffixOn: stream]!
>
>



Carpe Squeak!