Class: Faussaire::Wine

Inherits:
Object
  • Object
show all
Defined in:
lib/faussaire/wine.rb

Constant Summary collapse

DATA_PATH =
File.expand_path('../../locale/fr.yml', __dir__)

Class Method Summary collapse

Class Method Details

.bottle_typeString

Produces a random wine bottle type.

Examples:

Faussaire::Wine.bottle_type #=> "Cabernet Sauvignon"

Returns:

  • (String)


40
41
42
# File 'lib/faussaire/wine.rb', line 40

def bottle_type
  fetch('fr.faussaire.wine.bottle_types')
end

.licocoricoString

Produces a random wine feature called “Licocorico”.

Examples:

Faussaire::Wine.licocorico #=> "Licocorico Special Blend"

Returns:

  • (String)


88
89
90
# File 'lib/faussaire/wine.rb', line 88

def licocorico
  fetch('fr.faussaire.wine.licocorico')
end

.nameString

Produces a random wine name.

Examples:

Faussaire::Wine.name #=> "Chateau Margaux"

Returns:

  • (String)


16
17
18
# File 'lib/faussaire/wine.rb', line 16

def name
  fetch('fr.faussaire.wine.name')
end

.priceString

Produces a random wine price with 99 cents and a Euro (€) symbol. Distribution:

  • 50% chance for a price between 3.5 and 499 (Low range)

  • 35% chance for a price between 499 and 2999 (Middle range)

  • 10% chance for a price between 3000 and 301300 (Upper-High range)

  • 15% chance for a price between 301301 and 482000 (Legendary range)

Examples:

Faussaire::Wine.price #=> "39.99€"

Returns:

  • (String)


69
70
71
72
73
74
75
76
77
78
# File 'lib/faussaire/wine.rb', line 69

def price
  random_number = rand
  euros = case random_number
          when 0...0.5 then rand(3.5..499).floor
          when 0.5...0.85 then rand(500..2999).floor
          when 0.85...0.95 then rand(3000..301300).floor
          else rand(301301..482000).floor
          end
  "#{euros}.99€"
end

.regionString

Produces a random wine region.

Examples:

Faussaire::Wine.region #=> "Bordeaux"

Returns:

  • (String)


52
53
54
# File 'lib/faussaire/wine.rb', line 52

def region
  fetch('fr.faussaire.wine.region')
end

.typeString

Produces a random wine type or style.

Examples:

Faussaire::Wine.type #=> "Red Wine"

Returns:

  • (String)


28
29
30
# File 'lib/faussaire/wine.rb', line 28

def type
  fetch('fr.faussaire.wine.type')
end