Skip to content

Instantly share code, notes, and snippets.

@dreamr
Last active December 28, 2015 11:29
Show Gist options
  • Save dreamr/7493821 to your computer and use it in GitHub Desktop.
Save dreamr/7493821 to your computer and use it in GitHub Desktop.
module Yahtzee
module ScoreCardUpdater
module_function
def update(game_card)
->(placement, value) {
game_card.update!(placement => value)
}
end
end
end
# Use
updater = Yahtzee::ScoreCardUpdater.update(game_card)
score_card = subject.score([1,1,3,4,5], :aces, &updater)
score_card.aces #=> 2
score_card = subject.score([1,2,2,2,5], :twos, &updater)
score_card.twos #=> 6
score_card.aces #=> 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment