Skip to content

Instantly share code, notes, and snippets.

@rjungemann
Created October 26, 2010 20:33
Show Gist options
  • Save rjungemann/647740 to your computer and use it in GitHub Desktop.
Save rjungemann/647740 to your computer and use it in GitHub Desktop.
Example beer recipe class in Ruby
# an abstract beer recipe
class BeerRecipe
attr_accessor :name, :original_gravity, :terminal_gravity, :color, :alcohol
end
# create an empty list to store your recipes
recipes = []
# create a concrete beer recipe
pilsner = BeerRecipe.new
pilsner.name = "182 Bohemian Pilsner"
pilsner.original_gravity = 1.044
pilsner.color = 2.08
pilsner.bitterness = 36.8
pilsner.alcohol = 4.1
# add the recipe to your list of recipes
recipes.push pilsner
# inspect the list of recipes
puts recipes.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment