Class: PokerEngine::HandLevels::BaseLevel

Inherits:
Object
  • Object
show all
Defined in:
lib/poker_engine/hand_levels.rb

Overview

Abstract class for Hand level

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cards) ⇒ BaseLevel

Returns a new instance of BaseLevel.



9
10
11
# File 'lib/poker_engine/hand_levels.rb', line 9

def initialize(cards)
  @cards = cards
end

Instance Attribute Details

#cardsObject (readonly)

Returns the value of attribute cards.



7
8
9
# File 'lib/poker_engine/hand_levels.rb', line 7

def cards
  @cards
end

Instance Method Details

#<=>(other) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/poker_engine/hand_levels.rb', line 13

def <=>(other)
  unless other.instance_of?(self.class)
    fail "Can't detail compare hands of different level"
  end

  detail_compare(other)
end

#detail_compare(other) ⇒ Object



21
22
23
24
# File 'lib/poker_engine/hand_levels.rb', line 21

def detail_compare(other)
  cards.values_desc_by_occurency <=>
    other.cards.values_desc_by_occurency
end