Module: ESS::Helpers
- Included in:
- Element
- Defined in:
- lib/ess/helpers.rb
Class Method Summary collapse
-
.uuid(key = nil, prefix = 'ESSID:') ⇒ Object
Generates an UUID with the prefix specified, using the kay passed to it.
Class Method Details
.uuid(key = nil, prefix = 'ESSID:') ⇒ Object
Generates an UUID with the prefix specified, using the kay passed to it.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ess/helpers.rb', line 9 def self.uuid key=nil, prefix='ESSID:' new_id = nil if key.nil? new_id = SecureRandom.uuid else chars = Digest::MD5.hexdigest(key) new_id = chars[0..8] + '-' + chars[8..12] + '-' + chars[12..16] + '-' + chars[16..20] + '-' + chars[20..32] end return prefix + new_id end |