faker 2.3.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +85 -2
- data/README.md +2 -1
- data/lib/faker/blockchain/aeternity.rb +70 -0
- data/lib/faker/default/app.rb +2 -1
- data/lib/faker/default/appliance.rb +18 -0
- data/lib/faker/default/avatar.rb +2 -1
- data/lib/faker/default/chuck_norris.rb +1 -1
- data/lib/faker/default/date.rb +83 -2
- data/lib/faker/default/dessert.rb +27 -0
- data/lib/faker/default/device.rb +54 -0
- data/lib/faker/default/driving_licence.rb +2 -2
- data/lib/faker/default/electrical_components.rb +27 -0
- data/lib/faker/default/greek_philosophers.rb +18 -0
- data/lib/faker/default/industry_segments.rb +36 -0
- data/lib/faker/default/internet.rb +4 -1
- data/lib/faker/default/marketing.rb +9 -0
- data/lib/faker/default/military.rb +45 -0
- data/lib/faker/default/nation.rb +48 -5
- data/lib/faker/default/nato_phonetic_alphabet.rb +9 -0
- data/lib/faker/default/number.rb +124 -0
- data/lib/faker/default/restaurant.rb +54 -2
- data/lib/faker/default/science.rb +27 -0
- data/lib/faker/default/subscription.rb +45 -0
- data/lib/faker/default/superhero.rb +45 -0
- data/lib/faker/default/time.rb +85 -8
- data/lib/faker/default/world_cup.rb +50 -0
- data/lib/faker/games/dota.rb +47 -0
- data/lib/faker/games/heroes.rb +27 -0
- data/lib/faker/games/heroes_of_the_storm.rb +36 -0
- data/lib/faker/games/league_of_legends.rb +54 -0
- data/lib/faker/games/myst.rb +45 -0
- data/lib/faker/games/pokemon.rb +27 -0
- data/lib/faker/games/sonic_the_hedgehog.rb +27 -0
- data/lib/faker/games/witcher.rb +54 -0
- data/lib/faker/games/world_of_warcraft.rb +18 -0
- data/lib/faker/games/zelda.rb +1 -1
- data/lib/faker/japanese_media/dragon_ball.rb +9 -0
- data/lib/faker/japanese_media/one_piece.rb +54 -0
- data/lib/faker/japanese_media/sword_art_online.rb +36 -0
- data/lib/faker/movies/back_to_the_future.rb +28 -0
- data/lib/faker/movies/ghostbusters.rb +28 -0
- data/lib/faker/movies/harry_potter.rb +54 -0
- data/lib/faker/movies/hitchhikers_guide_to_the_galaxy.rb +69 -0
- data/lib/faker/movies/hobbit.rb +37 -0
- data/lib/faker/movies/lebowski.rb +27 -0
- data/lib/faker/movies/lord_of_the_rings.rb +28 -0
- data/lib/faker/movies/movie.rb +9 -0
- data/lib/faker/movies/princess_bride.rb +19 -0
- data/lib/faker/movies/star_wars.rb +94 -0
- data/lib/faker/movies/v_for_vendetta.rb +29 -0
- data/lib/faker/music/grateful_dead.rb +18 -0
- data/lib/faker/music/phish.rb +9 -0
- data/lib/faker/music/rock_band.rb +9 -0
- data/lib/faker/music/umphreys_mcgee.rb +9 -0
- data/lib/faker/sports/basketball.rb +36 -0
- data/lib/faker/sports/football.rb +45 -0
- data/lib/faker/tv_shows/aqua_teen_hunger_force.rb +9 -0
- data/lib/faker/tv_shows/bojack_horseman.rb +28 -0
- data/lib/faker/tv_shows/buffy.rb +45 -0
- data/lib/faker/tv_shows/community.rb +19 -0
- data/lib/faker/tv_shows/dr_who.rb +78 -2
- data/lib/faker/tv_shows/dumb_and_dumber.rb +28 -0
- data/lib/faker/tv_shows/family_guy.rb +28 -0
- data/lib/faker/tv_shows/friends.rb +27 -0
- data/lib/faker/tv_shows/game_of_thrones.rb +46 -0
- data/lib/faker/tv_shows/hey_arnold.rb +27 -0
- data/lib/faker/tv_shows/how_i_met_your_mother.rb +37 -0
- data/lib/faker/tv_shows/michael_scott.rb +13 -0
- data/lib/faker/tv_shows/new_girl.rb +19 -0
- data/lib/faker/tv_shows/parks_and_rec.rb +18 -0
- data/lib/faker/tv_shows/rick_and_morty.rb +28 -0
- data/lib/faker/tv_shows/ru_paul.rb +18 -0
- data/lib/faker/tv_shows/seinfeld.rb +28 -0
- data/lib/faker/tv_shows/silicon_valley.rb +75 -0
- data/lib/faker/tv_shows/simpsons.rb +28 -0
- data/lib/faker/tv_shows/south_park.rb +19 -0
- data/lib/faker/tv_shows/star_trek.rb +36 -0
- data/lib/faker/tv_shows/stargate.rb +28 -0
- data/lib/faker/tv_shows/stranger_things.rb +19 -0
- data/lib/faker/tv_shows/the_expanse.rb +36 -0
- data/lib/faker/tv_shows/the_fresh_prince_of_bel_air.rb +28 -0
- data/lib/faker/tv_shows/the_it_crowd.rb +37 -0
- data/lib/faker/tv_shows/the_thick_of_it.rb +28 -0
- data/lib/faker/tv_shows/twin_peaks.rb +28 -0
- data/lib/faker/tv_shows/venture_bros.rb +38 -0
- data/lib/faker/version.rb +1 -1
- data/lib/locales/en-TH.yml +360 -0
- data/lib/locales/en/color.yml +1 -1
- data/lib/locales/en/dr_who.yml +1 -1
- data/lib/locales/en/science.yml +1 -1
- data/lib/locales/ja.yml +7 -8
- data/lib/locales/th.yml +380 -0
- metadata +26 -17
@@ -52,9 +52,9 @@ module Faker
|
|
52
52
|
year = dob.year % 10
|
53
53
|
month = gender == :female ? dob.month + 50 : dob.month
|
54
54
|
# Rubocop's preferred formatting is pretty gory
|
55
|
-
# rubocop:disable FormatString
|
55
|
+
# rubocop:disable Style/FormatString
|
56
56
|
"#{decade}#{'%02d' % month}#{'%02d' % dob.day}#{year}"
|
57
|
-
# rubocop:enable FormatString
|
57
|
+
# rubocop:enable Style/FormatString
|
58
58
|
end
|
59
59
|
|
60
60
|
def gb_licence_checksum
|
@@ -5,14 +5,41 @@ module Faker
|
|
5
5
|
flexible :electrical_components
|
6
6
|
|
7
7
|
class << self
|
8
|
+
##
|
9
|
+
# Produces an active electrical component.
|
10
|
+
#
|
11
|
+
# @return [String]
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# Faker::ElectricalComponents.active #=> "Transistor"
|
15
|
+
#
|
16
|
+
# @faker.version 1.9.0
|
8
17
|
def active
|
9
18
|
fetch('electrical_components.active')
|
10
19
|
end
|
11
20
|
|
21
|
+
##
|
22
|
+
# Produces a passive electrical component.
|
23
|
+
#
|
24
|
+
# @return [String]
|
25
|
+
#
|
26
|
+
# @example
|
27
|
+
# Faker::ElectricalComponents.passive #=> "Resistor"
|
28
|
+
#
|
29
|
+
# @faker.version 1.9.0
|
12
30
|
def passive
|
13
31
|
fetch('electrical_components.passive')
|
14
32
|
end
|
15
33
|
|
34
|
+
##
|
35
|
+
# Produces an electromechanical electrical component.
|
36
|
+
#
|
37
|
+
# @return [String]
|
38
|
+
#
|
39
|
+
# @example
|
40
|
+
# Faker::ElectricalComponents.electromechanical #=> "Toggle Switch"
|
41
|
+
#
|
42
|
+
# @faker.version 1.9.0
|
16
43
|
def electromechanical
|
17
44
|
fetch('electrical_components.electromechanical')
|
18
45
|
end
|
@@ -3,10 +3,28 @@
|
|
3
3
|
module Faker
|
4
4
|
class GreekPhilosophers < Base
|
5
5
|
class << self
|
6
|
+
##
|
7
|
+
# Produces the name of a Greek philosopher.
|
8
|
+
#
|
9
|
+
# @return [String]
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# Faker::GreekPhilosophers.name #=> "Socrates"
|
13
|
+
#
|
14
|
+
# @faker.version 1.9.0
|
6
15
|
def name
|
7
16
|
fetch('greek_philosophers.names')
|
8
17
|
end
|
9
18
|
|
19
|
+
##
|
20
|
+
# Produces a quote from a Greek philosopher.
|
21
|
+
#
|
22
|
+
# @return [String]
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# Faker::GreekPhilosophers.quote #=> "Only the educated are free."
|
26
|
+
#
|
27
|
+
# @faker.version 1.9.0
|
10
28
|
def quote
|
11
29
|
fetch('greek_philosophers.quotes')
|
12
30
|
end
|
@@ -5,18 +5,54 @@ module Faker
|
|
5
5
|
flexible :industry_segments
|
6
6
|
|
7
7
|
class << self
|
8
|
+
##
|
9
|
+
# Produces the name of an industry.
|
10
|
+
#
|
11
|
+
# @return [String]
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# Faker::IndustrySegments.industry #=> "Basic Materials"
|
15
|
+
#
|
16
|
+
# @faker.version 1.9.2
|
8
17
|
def industry
|
9
18
|
fetch('industry_segments.industry')
|
10
19
|
end
|
11
20
|
|
21
|
+
##
|
22
|
+
# Produces the name of a super-sector of an industry.
|
23
|
+
#
|
24
|
+
# @return [String]
|
25
|
+
#
|
26
|
+
# @example
|
27
|
+
# Faker::IndustrySegments.super_sector #=> "Basic Resources"
|
28
|
+
#
|
29
|
+
# @faker.version 1.9.2
|
12
30
|
def super_sector
|
13
31
|
fetch('industry_segments.super_sector')
|
14
32
|
end
|
15
33
|
|
34
|
+
##
|
35
|
+
# Produces the name of a sector of an industry.
|
36
|
+
#
|
37
|
+
# @return [String]
|
38
|
+
#
|
39
|
+
# @example
|
40
|
+
# Faker::IndustrySegments.sector #=> "Industrial Metals & Mining"
|
41
|
+
#
|
42
|
+
# @faker.version 1.9.2
|
16
43
|
def sector
|
17
44
|
fetch('industry_segments.sector')
|
18
45
|
end
|
19
46
|
|
47
|
+
##
|
48
|
+
# Produces the name of a subsector of an industry.
|
49
|
+
#
|
50
|
+
# @return [String]
|
51
|
+
#
|
52
|
+
# @example
|
53
|
+
# Faker::IndustrySegments.industry #=> "Basic Materials"
|
54
|
+
#
|
55
|
+
# @faker.version 1.9.2
|
20
56
|
def sub_sector
|
21
57
|
fetch('industry_segments.sub_sector')
|
22
58
|
end
|
@@ -73,6 +73,8 @@ module Faker
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
+
# rubocop:disable Metrics/ParameterLists
|
77
|
+
|
76
78
|
##
|
77
79
|
# Produces a randomized string of characters suitable for passwords
|
78
80
|
#
|
@@ -95,8 +97,8 @@ module Faker
|
|
95
97
|
# Faker::Internet.password(min_length: 10, max_length: 20, mix_case: true, special_characters: true) #=> "*%NkOnJsH4"
|
96
98
|
#
|
97
99
|
# @faker.version 2.1.3
|
98
|
-
# rubocop:disable Metrics/ParameterLists
|
99
100
|
def password(legacy_min_length = NOT_GIVEN, legacy_max_length = NOT_GIVEN, legacy_mix_case = NOT_GIVEN, legacy_special_characters = NOT_GIVEN, min_length: 8, max_length: 16, mix_case: true, special_characters: false)
|
101
|
+
# rubocop:enable Metrics/ParameterLists
|
100
102
|
warn_for_deprecated_arguments do |keywords|
|
101
103
|
keywords << :min_length if legacy_min_length != NOT_GIVEN
|
102
104
|
keywords << :max_length if legacy_max_length != NOT_GIVEN
|
@@ -239,6 +241,7 @@ module Faker
|
|
239
241
|
"#{ip_v6_address}/#{rand(1..127)}"
|
240
242
|
end
|
241
243
|
|
244
|
+
# rubocop:disable Metrics/ParameterLists
|
242
245
|
def url(legacy_host = NOT_GIVEN, legacy_path = NOT_GIVEN, legacy_scheme = NOT_GIVEN, host: domain_name, path: "/#{username}", scheme: 'http')
|
243
246
|
# rubocop:enable Metrics/ParameterLists
|
244
247
|
warn_for_deprecated_arguments do |keywords|
|
@@ -5,6 +5,15 @@ module Faker
|
|
5
5
|
flexible :marketing
|
6
6
|
|
7
7
|
class << self
|
8
|
+
##
|
9
|
+
# Produces the name of a video game console or platform.
|
10
|
+
#
|
11
|
+
# @return [String]
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# Faker::Marketing.buzzwords #=> "rubber meets the road"
|
15
|
+
#
|
16
|
+
# @faker.version 1.9.4
|
8
17
|
def buzzwords
|
9
18
|
fetch('marketing.buzzwords')
|
10
19
|
end
|
@@ -3,22 +3,67 @@
|
|
3
3
|
module Faker
|
4
4
|
class Military < Base
|
5
5
|
class << self
|
6
|
+
##
|
7
|
+
# Produces a rank in the U.S. Army.
|
8
|
+
#
|
9
|
+
# @return [String]
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# Faker::Military.army_rank #=> "Staff Sergeant"
|
13
|
+
#
|
14
|
+
# @faker.version 1.9.0
|
6
15
|
def army_rank
|
7
16
|
fetch('military.army_rank')
|
8
17
|
end
|
9
18
|
|
19
|
+
##
|
20
|
+
# Produces a rank in the U.S. Marines.
|
21
|
+
#
|
22
|
+
# @return [String]
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# Faker::Military.marines_rank #=> "Gunnery Sergeant"
|
26
|
+
#
|
27
|
+
# @faker.version 1.9.0
|
10
28
|
def marines_rank
|
11
29
|
fetch('military.marines_rank')
|
12
30
|
end
|
13
31
|
|
32
|
+
##
|
33
|
+
# Produces a rank in the U.S. Navy.
|
34
|
+
#
|
35
|
+
# @return [String]
|
36
|
+
#
|
37
|
+
# @example
|
38
|
+
# Faker::Military.navy_rank #=> "Seaman"
|
39
|
+
#
|
40
|
+
# @faker.version 1.9.0
|
14
41
|
def navy_rank
|
15
42
|
fetch('military.navy_rank')
|
16
43
|
end
|
17
44
|
|
45
|
+
##
|
46
|
+
# Produces a rank in the U.S. Air Force.
|
47
|
+
#
|
48
|
+
# @return [String]
|
49
|
+
#
|
50
|
+
# @example
|
51
|
+
# Faker::Military.air_force_rank #=> "Captain"
|
52
|
+
#
|
53
|
+
# @faker.version 1.9.0
|
18
54
|
def air_force_rank
|
19
55
|
fetch('military.air_force_rank')
|
20
56
|
end
|
21
57
|
|
58
|
+
##
|
59
|
+
# Produces a U.S. Department of Defense Paygrade.
|
60
|
+
#
|
61
|
+
# @return [String]
|
62
|
+
#
|
63
|
+
# @example
|
64
|
+
# Faker::Military.dod_paygrade #=> "E-6"
|
65
|
+
#
|
66
|
+
# @faker.version 1.9.0
|
22
67
|
def dod_paygrade
|
23
68
|
fetch('military.dod_paygrade')
|
24
69
|
end
|
data/lib/faker/default/nation.rb
CHANGED
@@ -4,27 +4,70 @@ module Faker
|
|
4
4
|
class Nation < Base
|
5
5
|
flexible :nation
|
6
6
|
class << self
|
7
|
-
|
7
|
+
##
|
8
|
+
# Produces a random nationality.
|
9
|
+
#
|
10
|
+
# @return [String]
|
11
|
+
#
|
12
|
+
# @example
|
13
|
+
# Faker::Nation.nationality #=> "Nepalese"
|
14
|
+
#
|
15
|
+
# @faker.version 1.9.0
|
8
16
|
def nationality
|
9
17
|
fetch('nation.nationality')
|
10
18
|
end
|
11
19
|
|
12
|
-
#
|
20
|
+
# rubocop:disable Style/AsciiComments
|
21
|
+
|
22
|
+
##
|
23
|
+
# Produces a random national flag emoji.
|
24
|
+
#
|
25
|
+
# @return [String]
|
26
|
+
#
|
27
|
+
# @example
|
28
|
+
# Faker::Nation.flag #=> "🇫🇮"
|
29
|
+
#
|
30
|
+
# @faker.version 1.9.0
|
13
31
|
def flag
|
14
32
|
sample(translate('faker.nation.flag')).pack('C*').force_encoding('utf-8')
|
15
33
|
end
|
34
|
+
# rubocop:enable Style/AsciiComments
|
16
35
|
|
17
|
-
|
36
|
+
##
|
37
|
+
# Produces a random national language.
|
38
|
+
#
|
39
|
+
# @return [String]
|
40
|
+
#
|
41
|
+
# @example
|
42
|
+
# Faker::Nation.language #=> "Nepali"
|
43
|
+
#
|
44
|
+
# @faker.version 1.9.0
|
18
45
|
def language
|
19
46
|
fetch('nation.language')
|
20
47
|
end
|
21
48
|
|
22
|
-
|
49
|
+
##
|
50
|
+
# Produces a random capital city.
|
51
|
+
#
|
52
|
+
# @return [String]
|
53
|
+
#
|
54
|
+
# @example
|
55
|
+
# Faker::Nation.capital_city #=> "Kathmandu"
|
56
|
+
#
|
57
|
+
# @faker.version 1.9.0
|
23
58
|
def capital_city
|
24
59
|
fetch('nation.capital_city')
|
25
60
|
end
|
26
61
|
|
27
|
-
|
62
|
+
##
|
63
|
+
# Produces a random national sport.
|
64
|
+
#
|
65
|
+
# @return [String]
|
66
|
+
#
|
67
|
+
# @example
|
68
|
+
# Faker::Nation.national_sport #=> "dandi biyo"
|
69
|
+
#
|
70
|
+
# @faker.version 1.9.0
|
28
71
|
def national_sport
|
29
72
|
fetch('team.sport')
|
30
73
|
end
|
@@ -3,6 +3,15 @@
|
|
3
3
|
module Faker
|
4
4
|
class NatoPhoneticAlphabet < Base
|
5
5
|
class << self
|
6
|
+
##
|
7
|
+
# Produces a code word from the NATO phonetic alphabet.
|
8
|
+
#
|
9
|
+
# @return [String]
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# Faker::NatoPhoneticAlphabet.code_word #=> "Hotel"
|
13
|
+
#
|
14
|
+
# @faker.version 1.9.0
|
6
15
|
def code_word
|
7
16
|
fetch('nato_phonetic_alphabet.code_word')
|
8
17
|
end
|
data/lib/faker/default/number.rb
CHANGED
@@ -3,6 +3,16 @@
|
|
3
3
|
module Faker
|
4
4
|
class Number < Base
|
5
5
|
class << self
|
6
|
+
##
|
7
|
+
# Produce a random number.
|
8
|
+
#
|
9
|
+
# @param digits [Integer] Number of digits that the generated number should have.
|
10
|
+
# @return [Integer]
|
11
|
+
#
|
12
|
+
# @example
|
13
|
+
# Faker::Number.number(digits: 10) #=> 1968353479
|
14
|
+
#
|
15
|
+
# @faker.version 1.0.0
|
6
16
|
def number(legacy_digits = NOT_GIVEN, digits: 10)
|
7
17
|
warn_for_deprecated_arguments do |keywords|
|
8
18
|
keywords << :digits if legacy_digits != NOT_GIVEN
|
@@ -15,6 +25,16 @@ module Faker
|
|
15
25
|
([non_zero_digit] + generate(digits - 1)).join.to_i
|
16
26
|
end
|
17
27
|
|
28
|
+
##
|
29
|
+
# Produce a random number with a leading zero.
|
30
|
+
#
|
31
|
+
# @param digits [Integer] Number of digits that the generated number should have.
|
32
|
+
# @return [String]
|
33
|
+
#
|
34
|
+
# @example
|
35
|
+
# Faker::Number.leading_zero_number(digits: 10) #=> "0669336915"
|
36
|
+
#
|
37
|
+
# @faker.version 1.0.0
|
18
38
|
def leading_zero_number(legacy_digits = NOT_GIVEN, digits: 10)
|
19
39
|
warn_for_deprecated_arguments do |keywords|
|
20
40
|
keywords << :digits if legacy_digits != NOT_GIVEN
|
@@ -23,6 +43,16 @@ module Faker
|
|
23
43
|
'0' + (2..digits).collect { digit }.join
|
24
44
|
end
|
25
45
|
|
46
|
+
##
|
47
|
+
# Produce a number with a number of digits, preserves leading zeroes.
|
48
|
+
#
|
49
|
+
# @param digits [Integer] Number of digits that the generated number should have.
|
50
|
+
# @return [String]
|
51
|
+
#
|
52
|
+
# @example
|
53
|
+
# Faker::Number.decimal_part(digits: 2) #=> "09"
|
54
|
+
#
|
55
|
+
# @faker.version 1.0.0
|
26
56
|
def decimal_part(legacy_digits = NOT_GIVEN, digits: 10)
|
27
57
|
warn_for_deprecated_arguments do |keywords|
|
28
58
|
keywords << :digits if legacy_digits != NOT_GIVEN
|
@@ -36,6 +66,18 @@ module Faker
|
|
36
66
|
leading_zero_number(digits: digits) + num.to_s
|
37
67
|
end
|
38
68
|
|
69
|
+
##
|
70
|
+
# Produces a float.
|
71
|
+
#
|
72
|
+
# @param l_digits [Integer] Number of digits that the generated decimal should have to the left of the decimal point.
|
73
|
+
# @param r_digits [Integer] Number of digits that the generated decimal should have to the right of the decimal point.
|
74
|
+
# @return [Float]
|
75
|
+
#
|
76
|
+
# @example
|
77
|
+
# Faker::Number.decimal(l_digits: 2) #=> 11.88
|
78
|
+
# Faker::Number.decimal(l_digits: 3, r_digits: 3) #=> 181.843
|
79
|
+
#
|
80
|
+
# @faker.version 1.0.0
|
39
81
|
def decimal(legacy_l_digits = NOT_GIVEN, legacy_r_digits = NOT_GIVEN, l_digits: 5, r_digits: 2)
|
40
82
|
warn_for_deprecated_arguments do |keywords|
|
41
83
|
keywords << :l_digits if legacy_l_digits != NOT_GIVEN
|
@@ -53,14 +95,42 @@ module Faker
|
|
53
95
|
"#{l_d}.#{r_d}".to_f
|
54
96
|
end
|
55
97
|
|
98
|
+
##
|
99
|
+
# Produces a non-zero single-digit integer.
|
100
|
+
#
|
101
|
+
# @return [Integer]
|
102
|
+
#
|
103
|
+
# @example
|
104
|
+
# Faker::Number.non_zero_digit #=> 8
|
105
|
+
#
|
106
|
+
# @faker.version 1.0.0
|
56
107
|
def non_zero_digit
|
57
108
|
rand(1..9)
|
58
109
|
end
|
59
110
|
|
111
|
+
##
|
112
|
+
# Produces a single-digit integer.
|
113
|
+
#
|
114
|
+
# @return [Integer]
|
115
|
+
#
|
116
|
+
# @example
|
117
|
+
# Faker::Number.digit #=> 1
|
118
|
+
#
|
119
|
+
# @faker.version 1.0.0
|
60
120
|
def digit
|
61
121
|
rand(10)
|
62
122
|
end
|
63
123
|
|
124
|
+
##
|
125
|
+
# Produces a number in hexadecimal format.
|
126
|
+
#
|
127
|
+
# @param digits [Integer] Number of digits in the he
|
128
|
+
# @return [String]
|
129
|
+
#
|
130
|
+
# @example
|
131
|
+
# Faker::Number.hexadecimal(digits: 3) #=> "e74"
|
132
|
+
#
|
133
|
+
# @faker.version 1.0.0
|
64
134
|
def hexadecimal(legacy_digits = NOT_GIVEN, digits: 6)
|
65
135
|
warn_for_deprecated_arguments do |keywords|
|
66
136
|
keywords << :digits if legacy_digits != NOT_GIVEN
|
@@ -71,6 +141,17 @@ module Faker
|
|
71
141
|
hex
|
72
142
|
end
|
73
143
|
|
144
|
+
##
|
145
|
+
# Produces a float given a mean and standard deviation.
|
146
|
+
#
|
147
|
+
# @param mean [Integer]
|
148
|
+
# @param standard_deviation [Integer, Float]
|
149
|
+
# @return [Float]
|
150
|
+
#
|
151
|
+
# @example
|
152
|
+
# Faker::Number.normal(mean: 50, standard_deviation: 3.5) #=> 47.14669604069156
|
153
|
+
#
|
154
|
+
# @faker.version 1.0.0
|
74
155
|
def normal(legacy_mean = NOT_GIVEN, legacy_standard_deviation = NOT_GIVEN, mean: 1, standard_deviation: 1)
|
75
156
|
warn_for_deprecated_arguments do |keywords|
|
76
157
|
keywords << :mean if legacy_mean != NOT_GIVEN
|
@@ -83,6 +164,17 @@ module Faker
|
|
83
164
|
mean + scale * Math.cos(theta)
|
84
165
|
end
|
85
166
|
|
167
|
+
##
|
168
|
+
# Produces a number between two provided values. Boundaries are inclusive.
|
169
|
+
#
|
170
|
+
# @param from [Integer] The lowest number to include.
|
171
|
+
# @param to [Integer] The highest number to include.
|
172
|
+
# @return [Integer]
|
173
|
+
#
|
174
|
+
# @example
|
175
|
+
# Faker::Number.between(from: 1, to: 10) #=> 7
|
176
|
+
#
|
177
|
+
# @faker.version 1.0.0
|
86
178
|
def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 1.00, to: 5000.00)
|
87
179
|
warn_for_deprecated_arguments do |keywords|
|
88
180
|
keywords << :from if legacy_from != NOT_GIVEN
|
@@ -92,6 +184,16 @@ module Faker
|
|
92
184
|
Faker::Base.rand_in_range(from, to)
|
93
185
|
end
|
94
186
|
|
187
|
+
##
|
188
|
+
# Produces a number within two provided values. Boundaries are inclusive or exclusive depending on the range passed.
|
189
|
+
#
|
190
|
+
# @param range [Range] The range from which to generate a number.
|
191
|
+
# @return [Integer]
|
192
|
+
#
|
193
|
+
# @example
|
194
|
+
# Faker::Number.within(range: 1..10) #=> 7
|
195
|
+
#
|
196
|
+
# @faker.version 1.0.0
|
95
197
|
def within(legacy_range = NOT_GIVEN, range: 1.00..5000.00)
|
96
198
|
warn_for_deprecated_arguments do |keywords|
|
97
199
|
keywords << :range if legacy_range != NOT_GIVEN
|
@@ -100,6 +202,17 @@ module Faker
|
|
100
202
|
between(from: range.min, to: range.max)
|
101
203
|
end
|
102
204
|
|
205
|
+
##
|
206
|
+
# Produces a positive float.
|
207
|
+
#
|
208
|
+
# @param from [Integer] The lower boundary.
|
209
|
+
# @param to [Integer] The higher boundary.
|
210
|
+
# @return [Float]
|
211
|
+
#
|
212
|
+
# @example
|
213
|
+
# Faker::Number.positive #=> 235.59238499107653
|
214
|
+
#
|
215
|
+
# @faker.version 1.0.0
|
103
216
|
def positive(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: 1.00, to: 5000.00)
|
104
217
|
warn_for_deprecated_arguments do |keywords|
|
105
218
|
keywords << :from if legacy_from != NOT_GIVEN
|
@@ -111,6 +224,17 @@ module Faker
|
|
111
224
|
greater_than_zero(random_number)
|
112
225
|
end
|
113
226
|
|
227
|
+
##
|
228
|
+
# Produces a negative float.
|
229
|
+
#
|
230
|
+
# @param from [Integer] The lower boundary.
|
231
|
+
# @param to [Integer] The higher boundary.
|
232
|
+
# @return [Float]
|
233
|
+
#
|
234
|
+
# @example
|
235
|
+
# Faker::Number.negative #=> -4480.042585669558
|
236
|
+
#
|
237
|
+
# @faker.version 1.0.0
|
114
238
|
def negative(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from: -5000.00, to: -1.00)
|
115
239
|
warn_for_deprecated_arguments do |keywords|
|
116
240
|
keywords << :from if legacy_from != NOT_GIVEN
|