File: number.md

package info (click to toggle)
ruby-faker 3.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,596 kB
  • sloc: ruby: 20,656; sh: 6; makefile: 6
file content (50 lines) | stat: -rw-r--r-- 1,552 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Faker::Number

```ruby
# Produces a number of the specified digits where the leading digit is never 0
# Keyword arguments: digits
Faker::Number.number(digits: 10) #=> 1968353479

# Produces a number of the specified digits with a leading zero
# Keyword arguments: digits
Faker::Number.leading_zero_number(digits: 10) #=> "0669336915"

# Produces a 2-digit number, preserves leading 0's
# Keyword arguments: digits
Faker::Number.decimal_part(digits: 2) #=> "09"

# Produces a number with 2 digits leading and trailing the decimal
# Keyword arguments: l_digits
Faker::Number.decimal(l_digits: 2) #=> 11.88

# Specify different values for leading and trailing digits
# Keyword arguments: l_digits, r_digits
Faker::Number.decimal(l_digits: 3, r_digits: 3) #=> 181.843

# Keyword arguments: mean, standard_deviation
Faker::Number.normal(mean: 50, standard_deviation: 3.5) #=> 47.14669604069156

# Keyword arguments: digits
Faker::Number.hexadecimal(digits: 3) #=> "e74"

# Keyword arguments: digits
Faker::Number.binary(digits: 4) #=> "1010"

# Boundary numbers are inclusive
# Keyword arguments: from, to
Faker::Number.between(from: 1, to: 10) #=> 7
Faker::Number.between(from: 0.0, to: 1.0) #=> 0.7844640543957383

# Min and Max boundaries of range are inclusive
# Keyword arguments: range
Faker::Number.within(range: 1..10) #=> 7
Faker::Number.within(range: 0.0..1.0) #=> 0.7844640543957383

Faker::Number.positive #=> 235.59238499107653

Faker::Number.negative #=> -4480.042585669558

Faker::Number.non_zero_digit #=> 8

Faker::Number.digit #=> 1
```