Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/picolena/templates/lib/core_exts.rb

Instance Method Summary collapse

Instance Method Details

#base26_hash(length = Picolena::HashLength) ⇒ Object

Creates a “probably unique” id with the desired length, composed only of lowercase letters.



20
21
22
# File 'lib/picolena/templates/lib/core_exts.rb', line 20

def base26_hash(length=Picolena::HashLength)
  Digest::MD5.hexdigest(self).to_i(16).to_s(26).tr('0-9a-p', 'a-z')[-length,length]
end