Sha256: 0d6941055bfc55d9d3ada218df21f6728ee410a54ea9ec979e2a2533b6e0285d
Contents?: true
Size: 938 Bytes
Versions: 13
Compression:
Stored size: 938 Bytes
Contents
module Trax module Model class UUIDPrefix < String HEX_LETTER_RANGE = ('a'..'f').to_a.freeze HEX_DIGIT_RANGE = (0..9).to_a.freeze CHARACTER_RANGE = (HEX_DIGIT_RANGE + HEX_LETTER_RANGE).freeze PREFIX_LENGTH = 2 def self.all @all ||= begin CHARACTER_RANGE.repeated_permutation(PREFIX_LENGTH).to_a.reject! do |permutation| (HEX_LETTER_RANGE.include?(permutation[0]) && HEX_LETTER_RANGE.include?(permutation[1]) || HEX_DIGIT_RANGE.include?(permutation[0]) && HEX_DIGIT_RANGE.include?(permutation[1])) end.uniq.map do |character_array| new(character_array.join) end end end def index self.class.all.index(self) end def next self.class.all.at(index + 1) end def previous self.class.all.at(index - 1) end def to_s "#{self}" end end end end
Version data entries
13 entries across 13 versions & 1 rubygems