Class: Faker::Commerce
- Inherits:
-
Base
- Object
- Base
- Faker::Commerce
show all
- Defined in:
- lib/faker/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
5
6
7
|
# File 'lib/faker/commerce.rb', line 5
def color
fetch('commerce.color')
end
|
.department(max = 3, fixed_amount = false) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/faker/commerce.rb', line 9
def department(max = 3, fixed_amount = false)
num = max if fixed_amount
num ||= 1 + rand(max)
categories = categories(num)
if num > 1
merge_categories(categories)
else
categories[0]
end
end
|
.material ⇒ Object
26
27
28
|
# File 'lib/faker/commerce.rb', line 26
def material
fetch('commerce.product_name.material')
end
|
.price(range = 0..100.0) ⇒ Object
30
31
32
33
|
# File 'lib/faker/commerce.rb', line 30
def price(range=0..100.0)
random = Random::DEFAULT
(random.rand(range) * 100).floor/100.0
end
|
.product_name ⇒ Object
22
23
24
|
# File 'lib/faker/commerce.rb', line 22
def product_name
fetch('commerce.product_name.adjective') + ' ' + fetch('commerce.product_name.material') + ' ' + fetch('commerce.product_name.product')
end
|