Class: StartingHandRepository

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/rora/repository/starting_hand_repository.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStartingHandRepository

Returns a new instance of StartingHandRepository.



5
6
7
8
9
10
11
12
13
14
# File 'lib/rora/repository/starting_hand_repository.rb', line 5

def initialize
  @all = Array.new
  @distinct = Hash.new
  Deck.new.cards.combination(2) do |combination|
    starting_hand = StartingHand.new(combination)
    @all << starting_hand
    hash_key = starting_hand.cards.inject(1) {|product, card| product * card.rank.id } * (starting_hand.suited? ? 67 : 1)
    @distinct[hash_key] = starting_hand
  end
end

Instance Attribute Details

#allObject (readonly)

Returns the value of attribute all.



3
4
5
# File 'lib/rora/repository/starting_hand_repository.rb', line 3

def all
  @all
end

#distinctObject (readonly)

Returns the value of attribute distinct.



3
4
5
# File 'lib/rora/repository/starting_hand_repository.rb', line 3

def distinct
  @distinct
end

Instance Method Details

#all_starting_handsObject



16
17
18
# File 'lib/rora/repository/starting_hand_repository.rb', line 16

def all_starting_hands
  @all
end

#distinct_starting_handsObject



20
21
22
# File 'lib/rora/repository/starting_hand_repository.rb', line 20

def distinct_starting_hands
  @distinct.values
end