class EulerPoker::HandFactory

Public Class Methods

build_hand(cards) click to toggle source
# File lib/euler_poker/hand_factory.rb, line 35
def self.build_hand(cards)
  RANKED_HANDS
    .map { |h| h.new(cards) }
    .find{ |h| h.valid? }
end
hand(hand) click to toggle source
# File lib/euler_poker/hand_factory.rb, line 24
def self.hand(hand)
  cards = parse_cards(hand)
  build_hand(cards)
end
parse_cards(cards_string) click to toggle source
# File lib/euler_poker/hand_factory.rb, line 29
def self.parse_cards(cards_string)
  cards_string
    .split
    .map { |card_string| Card.new(card_string) }
end
round(round) click to toggle source
# File lib/euler_poker/hand_factory.rb, line 17
def self.round(round)
  cards = parse_cards(round)
  first = build_hand(cards.first(5))
  second = build_hand(cards.last(5))
  [first, second]
end