Class: Matchup

Inherits:
Object
  • Object
show all
Defined in:
lib/rpoker/matchup.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hand1, hand2) ⇒ Matchup

Returns a new instance of Matchup.



3
4
5
# File 'lib/rpoker/matchup.rb', line 3

def initialize(hand1, hand2)
  @hand1, @hand2 = hand1, hand2
end

Instance Attribute Details

#hand1Object (readonly)

Returns the value of attribute hand1.



2
3
4
# File 'lib/rpoker/matchup.rb', line 2

def hand1
  @hand1
end

#hand2Object (readonly)

Returns the value of attribute hand2.



2
3
4
# File 'lib/rpoker/matchup.rb', line 2

def hand2
  @hand2
end

Instance Method Details

#winnerObject



7
8
9
10
11
# File 'lib/rpoker/matchup.rb', line 7

def winner
  return hand1 if hand1.rank_idx < hand2.rank_idx
  return hand2 if hand2.rank_idx < hand1.rank_idx
  same_rank_winner
end