Class: Mnemosyne::DomainGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/mnemosyne/domain_generator.rb

Class Method Summary collapse

Class Method Details

.generate(length, domain_end) ⇒ Object



5
6
7
# File 'lib/mnemosyne/domain_generator.rb', line 5

def self.generate(length, domain_end)
    "#{SecureRandom.hex[0...length]}#{domain_end}"
end

.generate_with_regex(regex, domain_end) ⇒ Object



9
10
11
12
# File 'lib/mnemosyne/domain_generator.rb', line 9

def self.generate_with_regex(regex, domain_end)
    complete_regex = Regexp.new(regex.source + Regexp.escape(domain_end))
    complete_regex.random_example
end