forked from elixirs/faker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
beer.ex
170 lines (141 loc) · 3.09 KB
/
beer.ex
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
defmodule Faker.Beer do
import Faker, only: [localize: 1]
@moduledoc """
Functions for generating Beer related data
"""
@doc """
Returns a Beer brand string
## Examples
iex> Faker.Beer.brand()
"Paulaner"
iex> Faker.Beer.brand()
"Pabst Blue Ribbon"
iex> Faker.Beer.brand()
"Kirin Inchiban"
iex> Faker.Beer.brand()
"Birra Moretti"
"""
@spec brand() :: String.t()
localize(:brand)
@doc """
Returns a Beer name string
## Examples
iex> Faker.Beer.name()
"Duvel"
iex> Faker.Beer.name()
"Founders Kentucky Breakfast"
iex> Faker.Beer.name()
"Yeti Imperial Stout"
iex> Faker.Beer.name()
"Stone Imperial Russian Stout"
"""
@spec name() :: String.t()
localize(:name)
@doc """
Returns a Hop name string
## Examples
iex> Faker.Beer.hop()
"Eroica"
iex> Faker.Beer.hop()
"Bullion"
iex> Faker.Beer.hop()
"Mt. Rainier"
iex> Faker.Beer.hop()
"Citra"
"""
@spec hop() :: String.t()
localize(:hop)
@doc """
Returns a Yeast name string
## Examples
iex> Faker.Beer.yeast()
"2206 - Bavarian Lager"
iex> Faker.Beer.yeast()
"3763 - Roeselare Ale Blend"
iex> Faker.Beer.yeast()
"3711 - French Saison"
iex> Faker.Beer.yeast()
"3944 - Belgian Witbier"
"""
@spec yeast() :: String.t()
localize(:yeast)
@doc """
Returns a Malt name string
## Examples
iex> Faker.Beer.malt()
"Carapils"
iex> Faker.Beer.malt()
"Pale"
iex> Faker.Beer.malt()
"Rye malt"
iex> Faker.Beer.malt()
"Munich"
"""
@spec malt() :: String.t()
localize(:malt)
@doc """
Returns a Style name string
## Examples
iex> Faker.Beer.style()
"Stout"
iex> Faker.Beer.style()
"European Amber Lager"
iex> Faker.Beer.style()
"Strong Ale"
iex> Faker.Beer.style()
"German Wheat And Rye Beer"
"""
@spec style() :: String.t()
localize(:style)
@doc """
Returns an IBU(International Bitterness Unit) for a beer
## Examples
iex> Faker.Beer.ibu()
"59 IBU"
iex> Faker.Beer.ibu()
"10 IBU"
iex> Faker.Beer.ibu()
"56 IBU"
iex> Faker.Beer.ibu()
"85 IBU"
"""
@spec ibu :: String.t()
def ibu do
"#{Faker.random_between(5, 120)} IBU"
end
@doc """
Returns an alcohol percentage for a beer
## Examples
iex> Faker.Beer.alcohol()
"10.1%"
iex> Faker.Beer.alcohol()
"35.4%"
iex> Faker.Beer.alcohol()
"92.6%"
iex> Faker.Beer.alcohol()
"64.6%"
"""
@spec alcohol :: String.t()
def alcohol do
random_float() <> "%"
end
@doc """
Returns a blg for a beer
## Examples
iex> Faker.Beer.blg()
"10.1°Blg"
iex> Faker.Beer.blg()
"35.4°Blg"
iex> Faker.Beer.blg()
"92.6°Blg"
iex> Faker.Beer.blg()
"64.6°Blg"
"""
@spec blg :: String.t()
def blg do
random_float() <> "°Blg"
end
defp random_float do
"#{Faker.random_between(0, 99)}.#{Faker.random_between(0, 9)}"
end
end