refactor(api.percent): allow for round direction to be specified

This commit is contained in:
Cole Gleason
2014-01-24 15:31:08 -06:00
parent 5e0bcfd874
commit e76c81b3d7
2 changed files with 26 additions and 7 deletions
+6 -2
View File
@@ -188,9 +188,13 @@ api.taskDefaults = (task={}) ->
task.priority = 1 unless _.isNumber(task.priority) # hotfix for apiv1. once we're off apiv1, we can remove this
task
api.percent = (x,y) ->
api.percent = (x,y, dir) ->
switch dir
when "up" then roundFn = Math.ceil
when "down" then roundFn = Math.floor
else roundFn = Math.round
x=1 if x==0
Math.round(x/y*100)
roundFn(x/y*100)
###
Remove whitespace #FIXME are we using this anywwhere? Should we be?