Class: Trax::Model::UUIDPrefix
- Inherits:
-
String
- Object
- String
- Trax::Model::UUIDPrefix
- Defined in:
- lib/trax/model/uuid_prefix.rb
Constant Summary collapse
- 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
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.all ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/trax/model/uuid_prefix.rb', line 9 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 |
Instance Method Details
#index ⇒ Object
19 20 21 |
# File 'lib/trax/model/uuid_prefix.rb', line 19 def index self.class.all.index(self) end |
#next ⇒ Object
23 24 25 |
# File 'lib/trax/model/uuid_prefix.rb', line 23 def next self.class.all.at(index + 1) end |
#previous ⇒ Object
27 28 29 |
# File 'lib/trax/model/uuid_prefix.rb', line 27 def previous self.class.all.at(index - 1) end |
#to_s ⇒ Object
31 32 33 |
# File 'lib/trax/model/uuid_prefix.rb', line 31 def to_s "#{self}" end |