Creation/initialization utilities.
This commit is contained in:
parent
62fa2ab8b9
commit
b90c33bf04
@ -15,30 +15,24 @@ HlPerson class >> fromListName [
|
||||
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
{ #category : #initialization }
|
||||
HlPerson class >> fromListName: aString [
|
||||
| allNames |
|
||||
| allNames names |
|
||||
allNames := aString substrings
|
||||
collect: [:each | each first asString, each allButFirst asLowercase ].
|
||||
allNames size = 4
|
||||
ifTrue: [
|
||||
allNames size >= 3
|
||||
ifFalse: [
|
||||
^ self new
|
||||
givenName: allNames first, ' ', allNames second;
|
||||
familyName: allNames third, ' ', allNames fourth
|
||||
givenName: allNames second;
|
||||
familyName: allNames first.
|
||||
].
|
||||
names := '' writeStream.
|
||||
(allNames copyFrom: 3 to: allNames size) do: [:each |
|
||||
names nextPutAll: each, ' '.
|
||||
].
|
||||
allNames size = 3
|
||||
ifTrue: [
|
||||
^ self new
|
||||
givenName: allNames first, ' ', allNames second;
|
||||
familyName: allNames third.
|
||||
].
|
||||
allNames size = 2
|
||||
ifTrue: [
|
||||
^ self new
|
||||
givenName: allNames first;
|
||||
familyName: allNames second.
|
||||
].
|
||||
|
||||
familyName: allNames first, ' ', allNames second;
|
||||
givenName: names contents trimmed
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
|
Loading…
Reference in New Issue
Block a user