diff --git a/src/MiniDocs/AlphanumCounter.class.st b/src/MiniDocs/AlphanumCounter.class.st new file mode 100644 index 0000000..f6e3412 --- /dev/null +++ b/src/MiniDocs/AlphanumCounter.class.st @@ -0,0 +1,57 @@ +Class { + #name : #AlphanumCounter, + #superclass : #Object, + #instVars : [ + 'letters', + 'digits', + 'currentLetter', + 'currentDigit' + ], + #category : #MiniDocs +} + +{ #category : #accessing } +AlphanumCounter >> current [ + ^ self currentLetter asString, self currentDigit asString +] + +{ #category : #accessing } +AlphanumCounter >> currentDigit [ + + ^ currentDigit ifNil: [ currentDigit := self digits first ] +] + +{ #category : #accessing } +AlphanumCounter >> currentLetter [ + ^ currentLetter ifNil: [ currentLetter := self letters first ] +] + +{ #category : #accessing } +AlphanumCounter >> currentLetterIndex [ + ^ self letters detectIndex: [:n | n = self currentLetter] +] + +{ #category : #accessing } +AlphanumCounter >> digits [ + ^ digits ifNil: [ digits := 1 to: 9 ] +] + +{ #category : #accessing } +AlphanumCounter >> digits: aNumbersArray [ + digits := aNumbersArray +] + +{ #category : #accessing } +AlphanumCounter >> increase [ + (self currentDigit < self digits last) + ifTrue: [ currentDigit := currentDigit + 1 ] + ifFalse: [ + currentLetter := self letters at: (self currentLetterIndex + 1). + currentDigit := self digits first + ] +] + +{ #category : #accessing } +AlphanumCounter >> letters [ + ^ letters ifNil: [ letters := $A to: $Z ] +]