Creation/initialization utilities.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-04-28 15:05:45 -05:00
parent 62fa2ab8b9
commit b90c33bf04

View File

@ -15,30 +15,24 @@ HlPerson class >> fromListName [
] ]
{ #category : #accessing } { #category : #initialization }
HlPerson class >> fromListName: aString [ HlPerson class >> fromListName: aString [
| allNames | | allNames names |
allNames := aString substrings allNames := aString substrings
collect: [:each | each first asString, each allButFirst asLowercase ]. collect: [:each | each first asString, each allButFirst asLowercase ].
allNames size = 4 allNames size >= 3
ifTrue: [ ifFalse: [
^ self new ^ self new
givenName: allNames first, ' ', allNames second; givenName: allNames second;
familyName: allNames third, ' ', allNames fourth familyName: allNames first.
].
names := '' writeStream.
(allNames copyFrom: 3 to: allNames size) do: [:each |
names nextPutAll: each, ' '.
]. ].
allNames size = 3
ifTrue: [
^ self new ^ self new
givenName: allNames first, ' ', allNames second; familyName: allNames first, ' ', allNames second;
familyName: allNames third. givenName: names contents trimmed
].
allNames size = 2
ifTrue: [
^ self new
givenName: allNames first;
familyName: allNames second.
].
] ]
{ #category : #accessing } { #category : #accessing }