class Card

Constants

S3_URLS
SHORT_SUITS
SHORT_VALUES
SUITS
VALUES

Public Class Methods

all_cards() { |value, suit| ... } click to toggle source
# File lib/badcards/card.rb, line 103
def self.all_cards
  SUITS.each do |suit|
    VALUES.each do |value|
      yield value, suit
    end
  end
end
new(value, suit) click to toggle source
# File lib/badcards/card.rb, line 76
def initialize(value, suit)
  if !VALUES.include?(value) && !VALUES.include?(SHORT_VALUES[value])
    raise ArgumentError, "Invalid Card value"
  end
  if !SUITS.include?(suit) && !SUITS.include?(SHORT_SUITS[suit])
    raise ArgumentError, "Invalid Card suit"
  end
  @value = SHORT_VALUES[value] || value
  @suit = SHORT_SUITS[suit] || suit
end

Public Instance Methods

img() click to toggle source
# File lib/badcards/card.rb, line 95
def img
  S3_URLS["#{value.downcase}+#{suit.downcase}"]
end
suit() click to toggle source
# File lib/badcards/card.rb, line 91
def suit
  @suit
end
to_s() click to toggle source
# File lib/badcards/card.rb, line 99
def to_s
  "#{value} of #{suit}"
end
value() click to toggle source
# File lib/badcards/card.rb, line 87
def value
  @value
end