Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add colorName method to the Recipe class #4

Merged
merged 1 commit into from
Dec 19, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/recipe.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ class Brauhaus.Recipe extends Brauhaus.OptionConstructor
bottleCount: ->
Math.floor(@batchSize / @servingSize)

# Get a friendly human-readable color name
colorName: ->
Brauhaus.srmToName @color

# Scale this recipe, keeping gravity and bitterness the same
scale: (batchSize, boilSize) ->
earlyOg = 1.0
Expand Down
3 changes: 3 additions & 0 deletions test/recipe.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ describe 'Recipe', ->
it 'Should calculate color as 4.6 SRM', ->
assert.equal 4.6, recipe.color.toFixed(1)

it 'Should calculate colorName as yellow', ->
assert.equal 'yellow', recipe.colorName()

it 'Should calculate calories as 165 kcal', ->
assert.equal 165, Math.round(recipe.calories)

Expand Down