1
0
mirror of https://github.com/askn/faker.git synced 2023-08-10 21:13:01 +03:00

add decimal

This commit is contained in:
Aşkın Gedik 2016-01-07 09:31:24 +02:00
parent d0044abb6d
commit 7d8998e74d
3 changed files with 10 additions and 0 deletions

View File

@ -125,6 +125,8 @@ Faker::Name.title
```crystal ```crystal
Faker::Number.number(10) Faker::Number.number(10)
Faker::Number.decimal(2)
Faker::Number.decimal(2, 3)
Faker::Number.digit Faker::Number.digit
``` ```

View File

@ -91,6 +91,8 @@ puts Faker::Name.title
puts "\n\t### Faker::Number\n\n" puts "\n\t### Faker::Number\n\n"
puts Faker::Number.number(10) puts Faker::Number.number(10)
puts Faker::Number.decimal(2)
puts Faker::Number.decimal(2, 3)
puts Faker::Number.digit puts Faker::Number.digit
puts "\n\t### Faker::PhoneNumber\n\n" puts "\n\t### Faker::PhoneNumber\n\n"

View File

@ -7,5 +7,11 @@ module Faker
def self.digit def self.digit
rand(10).to_s rand(10).to_s
end end
def self.decimal(l_digits, r_digits = 2)
l_d = number(l_digits)
r_d = number(r_digits)
"#{l_d}.#{r_d}"
end
end end
end end