Class: Hand

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/hand_rank/test.rb

Instance Method Summary collapse

Constructor Details

#initialize(*card_strings) ⇒ Hand

Returns a new instance of Hand.



170
171
172
173
174
175
176
177
# File 'lib/hand_rank/test.rb', line 170

def initialize( *card_strings )
  @cards = card_strings.map do |string|
    Card.new(
      value: value = string.to_i,
      suit: string.gsub( value.to_s, '' ).to_sym,
    )
  end
end

Instance Method Details

#cardsObject



179
180
181
# File 'lib/hand_rank/test.rb', line 179

def cards
  @cards
end

#to_sObject



183
184
185
# File 'lib/hand_rank/test.rb', line 183

def to_s
  @cards.map(&:to_s).join(', ')
end