Module: RScale::UUID
- Included in:
- RScale
- Defined in:
- lib/rscale/uuid.rb
Instance Method Summary collapse
-
#uuid ⇒ Object
Generate uuid based on current configuration.
-
#uuid_local ⇒ Object
Generate pseudo-unique string if local system does not have uuid binary installed.
-
#uuid_system ⇒ Object
Generate uuid using system binary.
Instance Method Details
#uuid ⇒ Object
Generate uuid based on current configuration
4 5 6 |
# File 'lib/rscale/uuid.rb', line 4 def uuid RScale.config.uuid_system ? uuid_system : uuid_local end |
#uuid_local ⇒ Object
Generate pseudo-unique string if local system does not have uuid binary installed
9 10 11 12 13 14 15 16 17 |
# File 'lib/rscale/uuid.rb', line 9 def uuid_local values = [ rand(0x0010000), rand(0x0010000), rand(0x0010000), rand(0x0010000), rand(0x0010000), rand(0x1000000), rand(0x1000000), ] "%04x%04x%04x%04x%04x%06x%06x" % values end |
#uuid_system ⇒ Object
Generate uuid using system binary
20 21 22 |
# File 'lib/rscale/uuid.rb', line 20 def uuid_system `uuidgen`.strip.gsub(/-/,'') end |