-
-
Save Insood/513bda0beaaa5c4190a4b829940163e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SerialNumberGenerator | |
LABELS_PER_SERIAL_NUMBER = 2 | |
protected | |
attr_accessor :serial_number_counter | |
public | |
def initialize(start:) | |
self.serial_number_counter = start.to_i | |
end | |
def next() | |
sn = self.serial_number_counter.to_s.rjust(6,"0") | |
if self.serial_number_counter % LABELS_PER_SERIAL_NUMBER == 0 then | |
self.serial_number_counter +=1 | |
end | |
return sn | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment