Skip to content

Commit

Permalink
Merge pull request #4 from hecticjeff/recipe-color-name
Browse files Browse the repository at this point in the history
Add colorName method to the Recipe class. Fixes #4, #3.
  • Loading branch information
danielgtaylor committed Dec 19, 2013
2 parents 5b9b470 + 0172a78 commit a377794
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
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

0 comments on commit a377794

Please sign in to comment.