Module: OLE_QA::Framework::String_Factory

Extended by:
Factory_Helpers
Defined in:
lib/data_factory/string_factory.rb

Overview

Generate random alphabetic, numeric, or alphanumeric strings of a given length

Class Method Summary collapse

Class Method Details

.alpha(len = 9) ⇒ Object



22
23
24
# File 'lib/data_factory/string_factory.rb', line 22

def alpha(len = 9)
  str(len).upcase
end

.alphanumeric(len = 9) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/data_factory/string_factory.rb', line 30

def alphanumeric(len = 9)
  str_out = String.new
  len.times do
    str_out << (('A'..'Z').to_a + ('0'..'9').to_a).sample
  end
  str_out
end

.numeric(len = 9) ⇒ Object



26
27
28
# File 'lib/data_factory/string_factory.rb', line 26

def numeric(len = 9)
  num_str(len)
end

.phoneObject



38
39
40
41
42
43
44
# File 'lib/data_factory/string_factory.rb', line 38

def phone
  str_out = '555-'
  str_out << num_str(3)
  str_out << '-'
  str_out << num_str(4)
  str_out
end

.priceObject



46
47
48
49
# File 'lib/data_factory/string_factory.rb', line 46

def price
  str = String.new
  str << num_str(sampler(1..3)) << '.' << '00'
end