diff --git a/src/Brick-Glamorous/BrExplicitIdentityNormalizer.class.st b/src/Brick-Glamorous/BrExplicitIdentityNormalizer.class.st index 62f9b517..18335a68 100644 --- a/src/Brick-Glamorous/BrExplicitIdentityNormalizer.class.st +++ b/src/Brick-Glamorous/BrExplicitIdentityNormalizer.class.st @@ -2,12 +2,26 @@ Class { #name : #BrExplicitIdentityNormalizer, #superclass : #BrIdentityNormalizer, #instVars : [ - 'colors', - 'defaultColor' + 'candidates', + 'defaultCandidate' ], - #category : 'Brick-Glamorous-Normalizer' + #category : #'Brick-Glamorous-Normalizer' } +{ #category : #'instance creation' } +BrExplicitIdentityNormalizer class >> startingWithBlue [ + ^ self new + setIndexTo: Color blue; + yourself +] + +{ #category : #'instance creation' } +BrExplicitIdentityNormalizer class >> startingWithRed [ + ^ self new + setIndexTo: Color red; + yourself +] + { #category : #'instance creation' } BrExplicitIdentityNormalizer class >> withCommand: aBlock withColors: aCollection withDefaultColor: aColor [ @@ -18,34 +32,42 @@ BrExplicitIdentityNormalizer class >> withCommand: aBlock withColors: aCollectio ] { #category : #accessing } -BrExplicitIdentityNormalizer >> colors [ - - ^colors +BrExplicitIdentityNormalizer >> candidates [ + ^ candidates +] + +{ #category : #accessing } +BrExplicitIdentityNormalizer >> candidates: aCollection [ + candidates := aCollection ] { #category : #accessing } BrExplicitIdentityNormalizer >> colors: anObject [ + candidates := anObject +] + +{ #category : #accessing } +BrExplicitIdentityNormalizer >> defaultCandidate: anObject [ - colors := anObject + defaultCandidate := anObject ] { #category : #accessing } BrExplicitIdentityNormalizer >> defaultColor [ - ^defaultColor + ^defaultCandidate ] { #category : #accessing } BrExplicitIdentityNormalizer >> defaultColor: anObject [ - defaultColor := anObject + defaultCandidate := anObject ] { #category : #private } -BrExplicitIdentityNormalizer >> nextColor [ - - colorIndex := colorIndex + 1. - ^colorIndex > self colors size +BrExplicitIdentityNormalizer >> nextResult [ + resultIndex := resultIndex + 1. + ^resultIndex > self candidates size ifTrue: [ self defaultColor ] - ifFalse: [ self colors at: colorIndex ] + ifFalse: [ self candidates at: resultIndex ] ] diff --git a/src/Brick-Glamorous/BrIdentityNormalizer.class.st b/src/Brick-Glamorous/BrIdentityNormalizer.class.st index 27f35270..9f92d2b5 100644 --- a/src/Brick-Glamorous/BrIdentityNormalizer.class.st +++ b/src/Brick-Glamorous/BrIdentityNormalizer.class.st @@ -3,25 +3,11 @@ Class { #superclass : #BrGlamorousNormalizer, #instVars : [ 'dictionary', - 'colorIndex' + 'resultIndex' ], - #category : 'Brick-Glamorous-Normalizer' + #category : #'Brick-Glamorous-Normalizer' } -{ #category : #'instance creation' } -BrIdentityNormalizer class >> startingWithBlue [ - ^ self new - setIndexTo: Color blue; - yourself -] - -{ #category : #'instance creation' } -BrIdentityNormalizer class >> startingWithRed [ - ^ self new - setIndexTo: Color red; - yourself -] - { #category : #'instance creation' } BrIdentityNormalizer class >> withCommand: aBlock [ @@ -31,7 +17,7 @@ BrIdentityNormalizer class >> withCommand: aBlock [ ] { #category : #'initialize-release' } -BrIdentityNormalizer >> colors [ +BrIdentityNormalizer >> candidates [ ^ BrGlamorousColors distinctTenStrongColors ] @@ -39,24 +25,23 @@ BrIdentityNormalizer >> colors [ BrIdentityNormalizer >> initialize [ super initialize. - colorIndex := 0. + resultIndex := 0. dictionary := Dictionary new. command := #yourself ] { #category : #private } -BrIdentityNormalizer >> nextColor [ +BrIdentityNormalizer >> nextResult [ - colorIndex := colorIndex \\ self colors size + 1. - ^self colors at: colorIndex + resultIndex := resultIndex \\ self candidates size + 1. + ^self candidates at: resultIndex ] { #category : #private } -BrIdentityNormalizer >> setIndexTo: aColor [ - "colorAsSymbol has to be one of Color colorNames. - The method set the current index to the color given in parameter" +BrIdentityNormalizer >> setIndexTo: aCandidate [ + "The method set the current index to the candidate given in parameter" - colorIndex := (self colors indexOf: aColor) - 1 + resultIndex := (self candidates indexOf: aCandidate) - 1 ] { #category : #accessing } @@ -64,5 +49,5 @@ BrIdentityNormalizer >> value: anEntity [ ^ dictionary at: (command cull: anEntity) - ifAbsentPut: [ self nextColor ] + ifAbsentPut: [ self nextResult ] ] diff --git a/src/Brick-Glamorous/BrNormalizerExamples.class.st b/src/Brick-Glamorous/BrNormalizerExamples.class.st index 07690281..0733d7d1 100644 --- a/src/Brick-Glamorous/BrNormalizerExamples.class.st +++ b/src/Brick-Glamorous/BrNormalizerExamples.class.st @@ -1,7 +1,7 @@ Class { #name : #BrNormalizerExamples, #superclass : #Object, - #category : 'Brick-Glamorous-Normalizer' + #category : #'Brick-Glamorous-Normalizer' } { #category : #'explicit identity' } @@ -75,7 +75,7 @@ BrNormalizerExamples >> identityStartingWithBlue [ | n | n := BrIdentityNormalizer startingWithBlue. - self assert: n nextColor = Color blue + self assert: n nextResult = Color blue ] { #category : #identity } @@ -83,7 +83,7 @@ BrNormalizerExamples >> identityStartingWithRed [ | n | n := BrIdentityNormalizer startingWithRed. - self assert: n nextColor = Color red + self assert: n nextResult = Color red ] { #category : #identity }