Class: Faker::Number
- Inherits:
-
Base
- Object
- Base
- Faker::Number
show all
- Defined in:
- lib/faker/number.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, regexify, translate
Class Method Details
.decimal(l_digits, r_digits = 2) ⇒ Object
8
9
10
11
12
|
# File 'lib/faker/number.rb', line 8
def decimal(l_digits, r_digits = 2)
l_d = self.number(l_digits)
r_d = self.number(r_digits)
"#{l_d}.#{r_d}"
end
|
.digit ⇒ Object
14
15
16
|
# File 'lib/faker/number.rb', line 14
def digit
rand(9).to_s
end
|
.number(digits) ⇒ Object
4
5
6
|
# File 'lib/faker/number.rb', line 4
def number(digits)
rand(10 ** digits).to_s.rjust(digits, '0')
end
|