class Simplicard::Card

Constants

ACE
JACK
KING
QUEEN
VALID_VALUES

VALID_SUITS = [SPADES,CLUBS,DIAMONDS,HEARTS]

Attributes

suit[R]

this is the facevalue and suit of the card

value[R]

this is the facevalue and suit of the card

Public Class Methods

new(value, s) click to toggle source
# File lib/simplicard.rb, line 60
def initialize(value, s)
  @value = value
  # @suit = suit
  @suit = Suit.new(s)
  validation_check
end

Public Instance Methods

get_suit() click to toggle source
# File lib/simplicard.rb, line 72
def get_suit
  @suit
end
get_value() click to toggle source

this returns the value of the card. Depends on the game, the get_value can return different value than the facevalue

# File lib/simplicard.rb, line 69
def get_value
  @value
end
is_an_ace?() click to toggle source
# File lib/simplicard.rb, line 105
def is_an_ace?
  return true if @value == ACE
end
is_face_card?() click to toggle source
# File lib/simplicard.rb, line 97
def is_face_card?
  if [JACK,QUEEN,KING].include?(@value)
    return true
  else
    return false
  end
end
show() click to toggle source
# File lib/simplicard.rb, line 93
def show
  return "#{value_to_s} of #{@suit.suit_to_s}"
end
value_to_s() click to toggle source
# File lib/simplicard.rb, line 77
def value_to_s
  case @value
    when ACE
      "Ace"
    when JACK
      "Jack"
    when QUEEN
      "Queen"
    when KING
      "King"
    else
      @value.to_s
  end

end

Private Instance Methods

validation_check() click to toggle source
# File lib/simplicard.rb, line 111
def validation_check
  if !VALID_VALUES.include?(@value)
    raise ArgumentError.new("Card value is not valid")
  end

end