Class: Gamemaker::CardGame::Hand

Inherits:
Deck
  • Object
show all
Defined in:
lib/gamemaker/card_game/hand.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Deck

#<<, #==, #as_json, #draw, #draw!, #empty?, from_json, #length, #merge!, #put, #shuffle!, #to_a, #undraw

Constructor Details

#initialize(cards = []) ⇒ Hand

Returns a new instance of Hand.



15
16
17
# File 'lib/gamemaker/card_game/hand.rb', line 15

def initialize(cards = [])
  super(cards)
end

Class Method Details

.card_classObject

Raises:

  • (NotImplementedError)


4
5
6
# File 'lib/gamemaker/card_game/hand.rb', line 4

def self.card_class
  raise NotImplementedError, "Hand is an abstract class, use Hand.of(CardType) to create a usable subclass"
end

.of(card_class) ⇒ Object



8
9
10
11
12
13
# File 'lib/gamemaker/card_game/hand.rb', line 8

def self.of(card_class)
  Class.new(self) do
    define_singleton_method(:name) { super() || "#{card_class.name}Hand" }
    define_singleton_method(:card_class) { card_class }
  end
end