Skip to content

Instantly share code, notes, and snippets.

@jheg
Created November 24, 2014 21:27
Show Gist options
  • Save jheg/49e16f17300ae1be81dc to your computer and use it in GitHub Desktop.
Save jheg/49e16f17300ae1be81dc to your computer and use it in GitHub Desktop.
mixin def init
module BJCard
attr_reader :value
def initialize
@value = card_value
end
def card_value
if (2..10).include?(face)
face
elsif face == 'A'
11
else
face.to_i + 10
end
end
end
class Card
include BJCard
attr_reader :face, :suit
def initialize(face, suit)
@face = face
@suit = suit
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment