Created
October 26, 2010 20:33
-
-
Save rjungemann/647740 to your computer and use it in GitHub Desktop.
Example beer recipe class in Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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