Class: FactoryHelper::Commerce
- Inherits:
-
Base
- Object
- Base
- FactoryHelper::Commerce
show all
- Defined in:
- lib/factory-helper/commerce.rb
Constant Summary
Constants inherited
from Base
Base::Letters, Base::Numbers, Base::ULetters
Class Method Summary
collapse
Methods inherited from Base
bothify, fetch, flexible, letterify, method_missing, numerify, parse, rand_in_range, regexify, translate
Class Method Details
.color ⇒ Object
6
7
8
|
# File 'lib/factory-helper/commerce.rb', line 6
def color
fetch('commerce.color')
end
|
.department(max = 3, fixed_amount = false) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/factory-helper/commerce.rb', line 10
def department(max = 3, fixed_amount = false)
num = max if fixed_amount
num ||= 1 + FactoryHelper::Config.random.rand(max)
categories = categories(num)
if num > 1
merge_categories(categories)
else
categories[0]
end
end
|
.material ⇒ Object
27
28
29
|
# File 'lib/factory-helper/commerce.rb', line 27
def material
fetch('commerce.product_name.material')
end
|
.price ⇒ Object
31
32
33
34
|
# File 'lib/factory-helper/commerce.rb', line 31
def price
random = FactoryHelper::Config.random
(random.rand(0..100.0) * 100).floor/100.0
end
|
.product_name ⇒ Object
23
24
25
|
# File 'lib/factory-helper/commerce.rb', line 23
def product_name
fetch('commerce.product_name.adjective') + ' ' + fetch('commerce.product_name.material') + ' ' + fetch('commerce.product_name.product')
end
|