class Card
  attr_reader :rank, :suit
  VALUE_MAP = { "2" => 2,
                "3" => 3,
                "4" => 4,
                "5" => 5,
                "6" => 6,
                "7" => 7,
                "8" => 8,
                "9" => 9,
                "10" => 10,
                "Jack" => 11,
                "Queen" => 12,
                "King" => 13,
                "Ace" => 14
              }

  SUIT_MAP = {"Spades" => 0.75,
              "Hearts" => 0.5,
              "Clubs" => 0.25,
              "Diamonds" => 0 }

  include Comparable

  def to_s
    "#{rank} of #{suit}"
  end

  def initialize(rank, suit)
    @rank = rank
    @suit = suit
  end

  def value
    VALUE_MAP[rank.to_s]+SUIT_MAP[suit]
  end

  def <=>(other)
    value <=> other.value
  end

end

cards = [Card.new(2, 'Hearts'),
         Card.new(10, 'Diamonds'),
         Card.new('Ace', 'Clubs')]
puts cards
puts cards.min == Card.new(2, 'Hearts')
puts cards.max == Card.new('Ace', 'Clubs')

cards = [Card.new(5, 'Hearts')]
puts cards.min == Card.new(5, 'Hearts')
puts cards.max == Card.new(5, 'Hearts')

cards = [Card.new(4, 'Hearts'),
         Card.new(4, 'Diamonds'),
         Card.new(10, 'Clubs')]
puts cards.min.rank == 4
puts cards.max == Card.new(10, 'Clubs')

cards = [Card.new(7, 'Diamonds'),
         Card.new('Jack', 'Diamonds'),
         Card.new('Jack', 'Spades')]
puts cards.min == Card.new(7, 'Diamonds')
puts cards.max.rank == 'Jack'

cards = [Card.new(8, 'Diamonds'),
         Card.new(8, 'Clubs'),
         Card.new(8, 'Spades')]
puts cards.min.rank == 8
puts cards.max.rank == 8