module MuchFactory
Constants
- DAYS_IN_A_YEAR
- SECONDS_IN_DAY
- VERSION
Public Instance Methods
binary()
click to toggle source
# File lib/much-factory.rb, line 80 def binary type_cast(Random.binary, :binary) end
boolean()
click to toggle source
# File lib/much-factory.rb, line 84 def boolean type_cast(Random.integer.even?, :boolean) end
date()
click to toggle source
# File lib/much-factory.rb, line 23 def date @date ||= type_cast(Random.date_string, :date) @date + Random.integer(DAYS_IN_A_YEAR) end
datetime()
click to toggle source
# File lib/much-factory.rb, line 33 def datetime @datetime ||= type_cast(Random.datetime_string, :datetime) @datetime + (Random.float(DAYS_IN_A_YEAR) * SECONDS_IN_DAY).to_i end
dir_path(length = nil)
click to toggle source
# File lib/much-factory.rb, line 62 def dir_path(length = nil) type_cast(Random.dir_path_string(length), :string) end
Also aliased as: path
email(domain = nil, length = nil)
click to toggle source
# File lib/much-factory.rb, line 76 def email(domain = nil, length = nil) type_cast(Random.email_string(domain, length), :string) end
file_name(length = nil)
click to toggle source
# File lib/much-factory.rb, line 58 def file_name(length = nil) type_cast(Random.file_name_string(length), :string) end
file_path()
click to toggle source
# File lib/much-factory.rb, line 66 def file_path type_cast(Random.file_path_string, :string) end
float(max = nil, precision: Factory.integer(5))
click to toggle source
# File lib/much-factory.rb, line 15 def float(max = nil, precision: Factory.integer(5)) factor = (10**precision).to_f (type_cast(Random.float(max), :float) * factor).round / factor end
hex(length = nil)
click to toggle source
# File lib/much-factory.rb, line 54 def hex(length = nil) type_cast(Random.hex_string(length), :string) end
integer(max = nil)
click to toggle source
# File lib/much-factory.rb, line 11 def integer(max = nil) type_cast(Random.integer(max), :integer) end
slug(length = nil)
click to toggle source
# File lib/much-factory.rb, line 50 def slug(length = nil) type_cast(Random.string(length || 5), :string) end
string(length = nil)
click to toggle source
# File lib/much-factory.rb, line 38 def string(length = nil) type_cast(Random.string(length || 10), :string) end
symbol(*args)
click to toggle source
# File lib/much-factory.rb, line 42 def symbol(*args) string(*args).to_sym end
text(length = nil)
click to toggle source
# File lib/much-factory.rb, line 46 def text(length = nil) type_cast(Random.string(length || 20), :string) end
time()
click to toggle source
# File lib/much-factory.rb, line 28 def time @time ||= type_cast(Random.time_string, :time) @time + (Random.float(DAYS_IN_A_YEAR) * SECONDS_IN_DAY).to_i end
type_cast(value, type)
click to toggle source
# File lib/much-factory.rb, line 88 def type_cast(value, type) type_converter.send(type, value) end
type_converter()
click to toggle source
# File lib/much-factory.rb, line 92 def type_converter TypeConverter end
url(host = nil, length = nil)
click to toggle source
# File lib/much-factory.rb, line 72 def url(host = nil, length = nil) type_cast(Random.url_string(host, length), :string) end