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
|
# frozen_string_literal: true
module Faker
class Coffee < Base
flexible :coffee
class << self
##
# Produces a random blend name.
#
# @return [String]
#
# @example
# Faker::Coffee.blend_name #=> "Major Java"
#
# @faker.version 1.9.0
def blend_name
parse('coffee.blend_name')
end
##
# Produces a random coffee origin place.
#
# @return [String]
#
# @example
# Faker::Coffee.origin #=> "Oaxaca, Mexico"
#
# @faker.version 1.9.0
def origin
country = fetch('coffee.country')
region = fetch("coffee.regions.#{search_format(country)}")
"#{region}, #{country}"
end
##
# Produces a random coffee variety.
#
# @return [String]
#
# @example
# Faker::Coffee.variety #=> "Red Bourbon"
#
# @faker.version 1.9.0
def variety
fetch('coffee.variety')
end
##
# Produces a string containing a random description of a coffee's taste.
#
# @return [String]
#
# @example
# Faker::Coffee.notes #=> "dull, tea-like, cantaloupe, soy sauce, marshmallow"
#
# @faker.version 1.9.0
def notes
parse('coffee.notes')
end
##
# Produces a random coffee taste intensity.
#
# @return [String]
#
# @example
# Faker::Coffee.intensifier #=> "mild"
#
# @faker.version 1.9.0
def intensifier
fetch('coffee.intensifier')
end
private
def search_format(key)
key.split.length > 1 ? key.split.join('_').downcase : key.downcase
end
end
end
end
|