Class: Cardistry::Card

Inherits:
Object
  • Object
show all
Defined in:
lib/cardistry/card.rb

Constant Summary collapse

@@suits =
[]
@@kinds =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rank, suit = nil, kind = :pip, name = nil) ⇒ Card

Returns a new instance of Card.



8
9
10
11
12
13
# File 'lib/cardistry/card.rb', line 8

def initialize rank, suit = nil, kind = :pip, name = nil
  @rank = rank
  @suit = suit
  @kind = kind
  @name = name || default_name
end

Instance Attribute Details

#kindObject (readonly)

Returns the value of attribute kind.



3
4
5
# File 'lib/cardistry/card.rb', line 3

def kind
  @kind
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/cardistry/card.rb', line 3

def name
  @name
end

#rankObject (readonly)

Returns the value of attribute rank.



3
4
5
# File 'lib/cardistry/card.rb', line 3

def rank
  @rank
end

#suitObject (readonly)

Returns the value of attribute suit.



3
4
5
# File 'lib/cardistry/card.rb', line 3

def suit
  @suit
end

Class Method Details

.kindsObject



19
20
21
# File 'lib/cardistry/card.rb', line 19

def self.kinds
  @@kinds
end

.suitsObject



15
16
17
# File 'lib/cardistry/card.rb', line 15

def self.suits
  @@suits
end

Instance Method Details

#to_sObject



23
24
25
# File 'lib/cardistry/card.rb', line 23

def to_s
  @name
end