Module: Hammock::StringPatches::ClassMethods

Defined in:
lib/hammock/monkey_patches/string.rb

Constant Summary collapse

AZ09Chars =
('0'..'9').to_a +
(('a'..'z').to_a - %w[a e i o u]) +
(('A'..'Z').to_a - %w[A E I O U])

Instance Method Summary collapse

Instance Method Details

#af09(length = 1) ⇒ Object

Generates a random string consisting of length hexadecimal characters (i.e. matching [0-9a-f]length).



16
17
18
19
20
# File 'lib/hammock/monkey_patches/string.rb', line 16

def af09 length = 1
  (1..length).inject('') {|a, t|
    a << rand(16).to_s(16)
  }
end

#azAZ09(length = 1) ⇒ Object

Generates a random string consisting of length alphamuneric characters (i.e. matching [0-9a-zA-Z]length).



23
24
25
# File 'lib/hammock/monkey_patches/string.rb', line 23

def azAZ09 length = 1
  (1..length).inject('') {|a, t| a << AZ09Chars.rand }
end