Class: OLE_QA::Framework::String_Factory
- Inherits:
-
Object
- Object
- OLE_QA::Framework::String_Factory
- 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
20 21 22 23 24 25 26 |
# File 'lib/data_factory/string_factory.rb', line 20 def alpha(len = 9) str = String.new len.times do str << (('A'..'Z').to_a).sample end str end |
.alphanumeric(len = 9) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/data_factory/string_factory.rb', line 36 def alphanumeric(len = 9) str = String.new len.times do str << (('A'..'Z').to_a + ('0'..'9').to_a).sample end str end |
.numeric(len = 9) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/data_factory/string_factory.rb', line 28 def numeric(len = 9) str = String.new len.times do str << (('0'..'9').to_a).sample end str end |
.phone ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/data_factory/string_factory.rb', line 44 def phone str = '555-' 3.times {str << (('0'..'9').to_a).sample} str << '-' 4.times {str << (('0'..'9').to_a).sample} str end |