class EulerPoker::TwoPair

Public Instance Methods

extra_card() click to toggle source
# File lib/euler_poker/hands/two_pair.rb, line 23
def extra_card
  rank_counts
    .find { |rank, count| count == 1 }
    .first
end
high_pair_rank() click to toggle source
# File lib/euler_poker/hands/two_pair.rb, line 15
def high_pair_rank
  pair_ranks.max
end
instance_comparison(other) click to toggle source
# File lib/euler_poker/hands/two_pair.rb, line 5
def instance_comparison(other)
  if high_pair_rank != other.high_pair_rank
    high_pair_rank <=> other.high_pair_rank
  elsif low_pair_rank != other.low_pair_rank
    low_pair_rank <=> other.low_pair_rank
  else
    extra_card <=> other.extra_card
  end
end
low_pair_rank() click to toggle source
# File lib/euler_poker/hands/two_pair.rb, line 19
def low_pair_rank
  pair_ranks.min
end
valid?() click to toggle source
# File lib/euler_poker/hands/two_pair.rb, line 29
def valid?
  two_pair?
end

Private Instance Methods

pair_ranks() click to toggle source
# File lib/euler_poker/hands/two_pair.rb, line 35
def pair_ranks
  rank_counts
    .select { |rank, count| count == 2 }
    .keys
end