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.
]. ].
allNames size = 3 names := '' writeStream.
ifTrue: [ (allNames copyFrom: 3 to: allNames size) do: [:each |
^ self new names nextPutAll: each, ' '.
givenName: allNames first, ' ', allNames second; ].
familyName: allNames third. ^ self new
]. familyName: allNames first, ' ', allNames second;
allNames size = 2 givenName: names contents trimmed
ifTrue: [
^ self new
givenName: allNames first;
familyName: allNames second.
].
] ]
{ #category : #accessing } { #category : #accessing }