Alphanumeric counter facility.
This commit is contained in:
parent
e26334425f
commit
629a9e32ca
57
src/MiniDocs/AlphanumCounter.class.st
Normal file
57
src/MiniDocs/AlphanumCounter.class.st
Normal file
@ -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 ]
|
||||||
|
]
|
Loading…
Reference in New Issue
Block a user