forked from ebhomengo/niki
1
0
Fork 0
niki/vendor/github.com/brianvoe/gofakeit/v6/beer.go

339 lines
5.2 KiB
Go
Raw Normal View History

2024-04-26 19:30:35 +00:00
package gofakeit
import (
"math/rand"
"strconv"
)
// BeerName will return a random beer name
2024-04-26 19:30:35 +00:00
func BeerName() string {
2024-04-26 19:30:35 +00:00
return beerName(globalFaker.Rand)
2024-04-26 19:30:35 +00:00
}
// BeerName will return a random beer name
2024-04-26 19:30:35 +00:00
func (f *Faker) BeerName() string {
2024-04-26 19:30:35 +00:00
return beerName(f.Rand)
2024-04-26 19:30:35 +00:00
}
func beerName(r *rand.Rand) string {
2024-04-26 19:30:35 +00:00
return getRandValue(r, []string{"beer", "name"})
2024-04-26 19:30:35 +00:00
}
// BeerStyle will return a random beer style
2024-04-26 19:30:35 +00:00
func BeerStyle() string {
2024-04-26 19:30:35 +00:00
return beerStyle(globalFaker.Rand)
2024-04-26 19:30:35 +00:00
}
// BeerStyle will return a random beer style
2024-04-26 19:30:35 +00:00
func (f *Faker) BeerStyle() string {
2024-04-26 19:30:35 +00:00
return beerStyle(f.Rand)
2024-04-26 19:30:35 +00:00
}
func beerStyle(r *rand.Rand) string {
2024-04-26 19:30:35 +00:00
return getRandValue(r, []string{"beer", "style"})
2024-04-26 19:30:35 +00:00
}
// BeerHop will return a random beer hop
2024-04-26 19:30:35 +00:00
func BeerHop() string {
2024-04-26 19:30:35 +00:00
return beerHop(globalFaker.Rand)
2024-04-26 19:30:35 +00:00
}
// BeerHop will return a random beer hop
2024-04-26 19:30:35 +00:00
func (f *Faker) BeerHop() string {
2024-04-26 19:30:35 +00:00
return beerHop(f.Rand)
2024-04-26 19:30:35 +00:00
}
func beerHop(r *rand.Rand) string {
2024-04-26 19:30:35 +00:00
return getRandValue(r, []string{"beer", "hop"})
2024-04-26 19:30:35 +00:00
}
// BeerYeast will return a random beer yeast
2024-04-26 19:30:35 +00:00
func BeerYeast() string {
2024-04-26 19:30:35 +00:00
return beerYeast(globalFaker.Rand)
2024-04-26 19:30:35 +00:00
}
// BeerYeast will return a random beer yeast
2024-04-26 19:30:35 +00:00
func (f *Faker) BeerYeast() string {
2024-04-26 19:30:35 +00:00
return beerYeast(f.Rand)
2024-04-26 19:30:35 +00:00
}
func beerYeast(r *rand.Rand) string {
2024-04-26 19:30:35 +00:00
return getRandValue(r, []string{"beer", "yeast"})
2024-04-26 19:30:35 +00:00
}
// BeerMalt will return a random beer malt
2024-04-26 19:30:35 +00:00
func BeerMalt() string {
2024-04-26 19:30:35 +00:00
return beerMalt(globalFaker.Rand)
2024-04-26 19:30:35 +00:00
}
// BeerMalt will return a random beer malt
2024-04-26 19:30:35 +00:00
func (f *Faker) BeerMalt() string {
2024-04-26 19:30:35 +00:00
return beerMalt(f.Rand)
2024-04-26 19:30:35 +00:00
}
func beerMalt(r *rand.Rand) string {
2024-04-26 19:30:35 +00:00
return getRandValue(r, []string{"beer", "malt"})
2024-04-26 19:30:35 +00:00
}
// BeerAlcohol will return a random beer alcohol level between 2.0 and 10.0
2024-04-26 19:30:35 +00:00
func BeerAlcohol() string {
2024-04-26 19:30:35 +00:00
return beerAlcohol(globalFaker.Rand)
2024-04-26 19:30:35 +00:00
}
// BeerAlcohol will return a random beer alcohol level between 2.0 and 10.0
2024-04-26 19:30:35 +00:00
func (f *Faker) BeerAlcohol() string {
2024-04-26 19:30:35 +00:00
return beerAlcohol(f.Rand)
2024-04-26 19:30:35 +00:00
}
func beerAlcohol(r *rand.Rand) string {
2024-04-26 19:30:35 +00:00
return strconv.FormatFloat(float64Range(r, 2.0, 10.0), 'f', 1, 64) + "%"
2024-04-26 19:30:35 +00:00
}
// BeerIbu will return a random beer ibu value between 10 and 100
2024-04-26 19:30:35 +00:00
func BeerIbu() string {
2024-04-26 19:30:35 +00:00
return beerIbu(globalFaker.Rand)
2024-04-26 19:30:35 +00:00
}
// BeerIbu will return a random beer ibu value between 10 and 100
2024-04-26 19:30:35 +00:00
func (f *Faker) BeerIbu() string {
2024-04-26 19:30:35 +00:00
return beerIbu(f.Rand)
2024-04-26 19:30:35 +00:00
}
func beerIbu(r *rand.Rand) string {
2024-04-26 19:30:35 +00:00
return strconv.Itoa(randIntRange(r, 10, 100)) + " IBU"
2024-04-26 19:30:35 +00:00
}
// BeerBlg will return a random beer blg between 5.0 and 20.0
2024-04-26 19:30:35 +00:00
func BeerBlg() string {
2024-04-26 19:30:35 +00:00
return beerBlg(globalFaker.Rand)
2024-04-26 19:30:35 +00:00
}
// BeerBlg will return a random beer blg between 5.0 and 20.0
2024-04-26 19:30:35 +00:00
func (f *Faker) BeerBlg() string {
2024-04-26 19:30:35 +00:00
return beerBlg(f.Rand)
2024-04-26 19:30:35 +00:00
}
func beerBlg(r *rand.Rand) string {
2024-04-26 19:30:35 +00:00
return strconv.FormatFloat(float64Range(r, 5.0, 20.0), 'f', 1, 64) + "°Blg"
2024-04-26 19:30:35 +00:00
}
func addBeerLookup() {
2024-04-26 19:30:35 +00:00
AddFuncLookup("beername", Info{
Display: "Beer Name",
Category: "beer",
2024-04-26 19:30:35 +00:00
Description: "Specific brand or variety of beer",
Example: "Duvel",
Output: "string",
2024-04-26 19:30:35 +00:00
Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
2024-04-26 19:30:35 +00:00
return beerName(r), nil
2024-04-26 19:30:35 +00:00
},
})
AddFuncLookup("beerstyle", Info{
Display: "Beer Style",
Category: "beer",
2024-04-26 19:30:35 +00:00
Description: "Distinct characteristics and flavors of beer",
Example: "European Amber Lager",
Output: "string",
2024-04-26 19:30:35 +00:00
Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
2024-04-26 19:30:35 +00:00
return beerStyle(r), nil
2024-04-26 19:30:35 +00:00
},
})
AddFuncLookup("beerhop", Info{
Display: "Beer Hop",
Category: "beer",
2024-04-26 19:30:35 +00:00
Description: "The flower used in brewing to add flavor, aroma, and bitterness to beer",
Example: "Glacier",
Output: "string",
2024-04-26 19:30:35 +00:00
Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
2024-04-26 19:30:35 +00:00
return beerHop(r), nil
2024-04-26 19:30:35 +00:00
},
})
AddFuncLookup("beeryeast", Info{
Display: "Beer Yeast",
Category: "beer",
2024-04-26 19:30:35 +00:00
Description: "Microorganism used in brewing to ferment sugars, producing alcohol and carbonation in beer",
Example: "1388 - Belgian Strong Ale",
Output: "string",
2024-04-26 19:30:35 +00:00
Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
2024-04-26 19:30:35 +00:00
return beerYeast(r), nil
2024-04-26 19:30:35 +00:00
},
})
AddFuncLookup("beermalt", Info{
Display: "Beer Malt",
Category: "beer",
2024-04-26 19:30:35 +00:00
Description: "Processed barley or other grains, provides sugars for fermentation and flavor to beer",
Example: "Munich",
Output: "string",
2024-04-26 19:30:35 +00:00
Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
2024-04-26 19:30:35 +00:00
return beerMalt(r), nil
2024-04-26 19:30:35 +00:00
},
})
AddFuncLookup("beeralcohol", Info{
Display: "Beer Alcohol",
Category: "beer",
2024-04-26 19:30:35 +00:00
Description: "Measures the alcohol content in beer",
Example: "2.7%",
Output: "string",
2024-04-26 19:30:35 +00:00
Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
2024-04-26 19:30:35 +00:00
return beerAlcohol(r), nil
2024-04-26 19:30:35 +00:00
},
})
AddFuncLookup("beeribu", Info{
Display: "Beer IBU",
Category: "beer",
2024-04-26 19:30:35 +00:00
Description: "Scale measuring bitterness of beer from hops",
Example: "29 IBU",
Output: "string",
2024-04-26 19:30:35 +00:00
Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
2024-04-26 19:30:35 +00:00
return beerIbu(r), nil
2024-04-26 19:30:35 +00:00
},
})
AddFuncLookup("beerblg", Info{
Display: "Beer BLG",
Category: "beer",
2024-04-26 19:30:35 +00:00
Description: "Scale indicating the concentration of extract in worts",
Example: "6.4°Blg",
Output: "string",
2024-04-26 19:30:35 +00:00
Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
2024-04-26 19:30:35 +00:00
return beerBlg(r), nil
2024-04-26 19:30:35 +00:00
},
})
2024-04-26 19:30:35 +00:00
}