Skip to content

Commit

Permalink
#103 award explain loss
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jul 15, 2024
1 parent 1e2da89 commit 91fd9e0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/award.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,14 @@ def J.award(*rows)
explain = bills.map { |b| b[:reason] }.join(', ')
explain = " (#{explain})"
explain = '' if bills.size == 1 && bills.first[:basis]
{
points: total,
greeting: "You've earned #{format('%+d', total)} points for this#{explain}. "
}
greeting = [
'You\'ve ',
total.positive? ? 'earned' : 'got',
' ',
format('%+d', total),
' points for this',
explain,
'. '
].join
{ points: total, greeting: }
end

0 comments on commit 91fd9e0

Please sign in to comment.