Skip to content

Instantly share code, notes, and snippets.

@Insood
Created October 25, 2018 22:33
Show Gist options
  • Save Insood/513bda0beaaa5c4190a4b829940163e2 to your computer and use it in GitHub Desktop.
Save Insood/513bda0beaaa5c4190a4b829940163e2 to your computer and use it in GitHub Desktop.
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