class Identifiable::Stylists::Numeric
Public Class Methods
new(record:)
click to toggle source
# File lib/identifiable/stylists/numeric.rb, line 6 def initialize(record:) @record = record @scale = scale end
Public Instance Methods
random_id()
click to toggle source
# File lib/identifiable/stylists/numeric.rb, line 11 def random_id (SecureRandom.random_number(@scale.max - @scale.min) + @scale.min).to_s end
Private Instance Methods
scale()
click to toggle source
# File lib/identifiable/stylists/numeric.rb, line 17 def scale length = @record.class.identifiable_length minimum = 10**(length - 1) maximum = (10**length) - 1 minimum..maximum end