lib/cards_lib/card.rb in cards_lib-0.1.2 vs lib/cards_lib/card.rb in cards_lib-0.2.0

- old
+ new

@@ -6,11 +6,11 @@ @suit = if_hash_then_fetch(face, :suit) @rank = if_hash_then_fetch(face, :rank) @face = face_from_rank_and_suit(@rank, @suit) if face.is_a? Hash @face ||= face - @ranker = ranker.new(rank) + @ranker = ranker.new(self.rank) end def face @face end @@ -21,15 +21,25 @@ def rank @rank || @face[0] end + def value + @ranker.ranker + end + def pair?(other) self.rank == other.rank end + # equal by both rank and suit def ==(other) pair?(other) && self.suit == other.suit + end + + # equal by value + def eql?(other) + value == other.value end def <=>(other) @ranker.<=>(other) end