Module: MuchFactory
- Extended by:
- MuchFactory
- Included in:
- MuchFactory
- Defined in:
- lib/much-factory.rb,
lib/much-factory/version.rb
Defined Under Namespace
Modules: Random, TypeConverter
Constant Summary
collapse
- DAYS_IN_A_YEAR =
365
- SECONDS_IN_DAY =
24 * 60 * 60
- VERSION =
"0.2.1"
Instance Method Summary
collapse
Instance Method Details
#binary ⇒ Object
79
80
81
|
# File 'lib/much-factory.rb', line 79
def binary
type_cast(Random.binary, :binary)
end
|
#boolean ⇒ Object
83
84
85
|
# File 'lib/much-factory.rb', line 83
def boolean
type_cast(Random.integer.even?, :boolean)
end
|
#dir_path(length = nil) ⇒ Object
Also known as:
path
61
62
63
|
# File 'lib/much-factory.rb', line 61
def dir_path(length = nil)
type_cast(Random.dir_path_string(length), :string)
end
|
#email(domain = nil, length = nil) ⇒ Object
75
76
77
|
# File 'lib/much-factory.rb', line 75
def email(domain = nil, length = nil)
type_cast(Random.email_string(domain, length), :string)
end
|
#file_name(length = nil) ⇒ Object
57
58
59
|
# File 'lib/much-factory.rb', line 57
def file_name(length = nil)
type_cast(Random.file_name_string(length), :string)
end
|
#float(max = nil) ⇒ Object
15
16
17
|
# File 'lib/much-factory.rb', line 15
def float(max = nil)
type_cast(Random.float(max), :float)
end
|
#hex(length = nil) ⇒ Object
53
54
55
|
# File 'lib/much-factory.rb', line 53
def hex(length = nil)
type_cast(Random.hex_string(length), :string)
end
|
#integer(max = nil) ⇒ Object
11
12
13
|
# File 'lib/much-factory.rb', line 11
def integer(max = nil)
type_cast(Random.integer(max), :integer)
end
|
#slug(length = nil) ⇒ Object
49
50
51
|
# File 'lib/much-factory.rb', line 49
def slug(length = nil)
type_cast(Random.string(length || 5), :string)
end
|
#string(length = nil) ⇒ Object
37
38
39
|
# File 'lib/much-factory.rb', line 37
def string(length = nil)
type_cast(Random.string(length || 10), :string)
end
|
#symbol(*args) ⇒ Object
41
42
43
|
# File 'lib/much-factory.rb', line 41
def symbol(*args)
string(*args).to_sym
end
|
#text(length = nil) ⇒ Object
45
46
47
|
# File 'lib/much-factory.rb', line 45
def text(length = nil)
type_cast(Random.string(length || 20), :string)
end
|
#type_cast(value, type) ⇒ Object
87
88
89
|
# File 'lib/much-factory.rb', line 87
def type_cast(value, type)
type_converter.send(type, value)
end
|
#type_converter ⇒ Object
91
92
93
|
# File 'lib/much-factory.rb', line 91
def type_converter
TypeConverter
end
|
#url(host = nil, length = nil) ⇒ Object
71
72
73
|
# File 'lib/much-factory.rb', line 71
def url(host = nil, length = nil)
type_cast(Random.url_string(host, length), :string)
end
|