Class: StartingHandRepository
- Inherits:
-
Object
- Object
- StartingHandRepository
- Includes:
- Singleton
- Defined in:
- lib/rora/repository/starting_hand_repository.rb
Instance Attribute Summary collapse
-
#all ⇒ Object
readonly
Returns the value of attribute all.
-
#distinct ⇒ Object
readonly
Returns the value of attribute distinct.
Instance Method Summary collapse
- #all_starting_hands ⇒ Object
- #distinct_starting_hands ⇒ Object
-
#initialize ⇒ StartingHandRepository
constructor
A new instance of StartingHandRepository.
Constructor Details
#initialize ⇒ StartingHandRepository
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
#all ⇒ Object (readonly)
Returns the value of attribute all.
3 4 5 |
# File 'lib/rora/repository/starting_hand_repository.rb', line 3 def all @all end |
#distinct ⇒ Object (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_hands ⇒ Object
16 17 18 |
# File 'lib/rora/repository/starting_hand_repository.rb', line 16 def all_starting_hands @all end |
#distinct_starting_hands ⇒ Object
20 21 22 |
# File 'lib/rora/repository/starting_hand_repository.rb', line 20 def distinct_starting_hands @distinct.values end |