Class: WebFlow::RandomGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/webflow/random_generator.rb

Overview

This class is used by the WebFlow framework to generate the FlowExecutionKey which uniquely identifies a user flow execution.

It creates random alphanumeric strings with upper-case characters.

Constant Summary collapse

Chars =

Defines which characters are used to generate random strings

("A".."Z").to_a + ("0".."9").to_a

Class Method Summary collapse

Class Method Details

.random_string(len = 64) ⇒ Object

Generates a random string of the given length. By default, it’s 64 characters long.



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/webflow/random_generator.rb', line 34

def self::random_string(len = 64)
  
  # Initial string
  string = ""

  # Pick characters at random
  1.upto(len) { |i| string << Chars[rand(Chars.size-1)] }

  # Return the resulting string
  return string.to_s

end