Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Faker::Beer YARD docs #1790

Merged
merged 3 commits into from
Dec 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions lib/faker/default/beer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,106 @@ class Beer < Base
flexible :beer

class << self
##
# Produces a random beer name.
#
# @return [String]
#
# @example
# Faker::Beer.name #=> "Pliny The Elder"
#
# @faker.version 1.6.2
def name
fetch('beer.name')
end

##
# Produces a random beer style.
#
# @return [String]
#
# @example
# Faker::Beer.style #=> "Wood-aged Beer"
#
# @faker.version 1.6.2
def style
fetch('beer.style')
end

##
# Produces a random beer hops.
#
# @return [String]
#
# @example
# Faker::Beer.hop #=> "Sterling"
#
# @faker.version 1.6.2
def hop
fetch('beer.hop')
end

##
# Produces a random beer yeast.
#
# @return [String]
#
# @example
# Faker::Beer.yeast #=> "5335 - Lactobacillus"
#
# @faker.version 1.6.2
def yeast
fetch('beer.yeast')
end

##
# Produces a random beer malt.
#
# @return [String]
#
# @example
# Faker::Beer.malts #=> "Munich"
#
# @faker.version 1.6.2
def malts
fetch('beer.malt')
end

##
# Produces a random beer IBU.
#
# @return [String]
#
# @example
# Faker::Beer.ibu #=> "87 IBU"
#
# @faker.version 1.6.2
def ibu
rand(10..100).to_s + ' IBU'
end

##
# Produces a random beer alcohol percentage.
#
# @return [String]
#
# @example
# Faker::Beer.alcohol #=> "5.4%"
#
# @faker.version 1.6.2
def alcohol
rand(2.0..10.0).round(1).to_s + '%'
end

##
# Produces a random beer blg level.
#
# @return [String]
#
# @example
# Faker::Beer.blg #=> "5.1Blg"
#
# @faker.version 1.6.2
def blg
rand(5.0..20.0).round(1).to_s + '°Blg'
end
Expand Down