Class: BeerRecipe::FermentableWrapper

Inherits:
Wrapper
  • Object
show all
Defined in:
lib/beer_recipe/fermentable_wrapper.rb

Instance Method Summary collapse

Methods inherited from Wrapper

#blank?, #format_method, #initialize, #method_missing, #respond_to_missing?, set, wrap

Constructor Details

This class inherits a constructor from BeerRecipe::Wrapper

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class BeerRecipe::Wrapper

Instance Method Details

#amount_in_poundsObject



38
39
40
# File 'lib/beer_recipe/fermentable_wrapper.rb', line 38

def amount_in_pounds
  amount * 2.20462
end

#amount_percentObject



57
58
59
# File 'lib/beer_recipe/fermentable_wrapper.rb', line 57

def amount_percent
  amount / @recipe.total_grains * 100
end

#bitter_extract?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/beer_recipe/fermentable_wrapper.rb', line 34

def bitter_extract?
  !ibu_gal_per_lb.nil?
end

#color_classObject



42
43
44
45
46
47
48
49
50
51
# File 'lib/beer_recipe/fermentable_wrapper.rb', line 42

def color_class
  c = color_srm.to_i
  if c > 40
    'srm-max'
  elsif c < 1
    'srm-min'
  else
    "srm#{c}"
  end
end

#color_ebcObject



10
11
12
# File 'lib/beer_recipe/fermentable_wrapper.rb', line 10

def color_ebc
  color
end

#color_hexObject



53
54
55
# File 'lib/beer_recipe/fermentable_wrapper.rb', line 53

def color_hex
  "#%02x%02x%02x" % BeerRecipe::Formula.new.srm_to_rgb(color_srm)
end

#color_srmObject



14
15
16
# File 'lib/beer_recipe/fermentable_wrapper.rb', line 14

def color_srm
  @color_srm ||= BeerRecipe::Formula.new.ebc_to_srm(color_ebc)
end

#formatted_amountObject



2
3
4
# File 'lib/beer_recipe/fermentable_wrapper.rb', line 2

def formatted_amount
  "#{'%.2f' % amount}"
end

#formatted_colorObject



6
7
8
# File 'lib/beer_recipe/fermentable_wrapper.rb', line 6

def formatted_color
  "#{'%.0f' % color_ebc}"
end

#ibuObject



26
27
28
29
30
31
32
# File 'lib/beer_recipe/fermentable_wrapper.rb', line 26

def ibu
  if bitter_extract?
    amount_in_pounds * ibu_gal_per_lb / @recipe.gallons
  else
    0
  end
end

#mcuObject



22
23
24
# File 'lib/beer_recipe/fermentable_wrapper.rb', line 22

def mcu
  @mcu ||= BeerRecipe::Formula.new.mcu(amount, color_srm, @recipe.batch_size)
end

#srm_in_batchObject



18
19
20
# File 'lib/beer_recipe/fermentable_wrapper.rb', line 18

def srm_in_batch
  BeerRecipe::Formula.new.mcu_to_srm(mcu)
end