Module: Alcohol

Defined in:
lib/alcohol.rb

Overview

Calculate the alcohol content of beer

Class Method Summary collapse

Class Method Details

.by_volume(original, terminal) ⇒ Float

Note:

Extract must be measured in Plato

Calculates alcohol by volume

Examples:

Alcohol.by_volume 17.5, 3.2

Parameters:

  • original (Float)

    original Plato

  • terminal (Float)

    terminal Plato

Returns:

  • (Float)

    alcohol content by volume



31
32
33
# File 'lib/alcohol.rb', line 31

def self.by_volume original, terminal
  ((by_weight original, terminal) / 0.793573).round 1
end

.by_weight(original, terminal) ⇒ Float

Note:

Extract must be measured in Plato

Calculates alcohol by weight

Examples:

Alcohol.by_weight 15, 3

Parameters:

  • original (Float)

    original Plato

  • terminal (Float)

    terminal Plato

Returns:

  • (Float)

    alcohol content by weight



15
16
17
18
# File 'lib/alcohol.rb', line 15

def self.by_weight original, terminal
  ((original - ((0.1808 * original) + (0.8192 * terminal))) /
   (2.0665 - (0.010665 * original))).round 1
end