Class: Suit
- Inherits:
-
Object
- Object
- Suit
- Defined in:
- lib/rora/model/suit.rb
Overview
The four categories in a deck of cards.
Each card bears one of four symbols showing which suit it belongs to. A deck of cards has four suits: hearts, clubs, spades, and diamonds.
Constant Summary collapse
- HEART =
new(43, "H", "Heart")
- SPADE =
new(47, "S", "Spade")
- CLUB =
new(53, "C", "Club")
- DIAMOND =
new(59, "D", "Diamond")
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #==(suit) ⇒ Object
-
#initialize(id, key, value) ⇒ Suit
constructor
A new instance of Suit.
- #to_s ⇒ Object
Constructor Details
#initialize(id, key, value) ⇒ Suit
Returns a new instance of Suit.
10 11 12 13 14 |
# File 'lib/rora/model/suit.rb', line 10 def initialize(id, key, value) @id = id @key = key @value = value end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/rora/model/suit.rb', line 8 def id @id end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
8 9 10 |
# File 'lib/rora/model/suit.rb', line 8 def key @key end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
8 9 10 |
# File 'lib/rora/model/suit.rb', line 8 def value @value end |
Class Method Details
.get(key) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/rora/model/suit.rb', line 20 def self.get(key) self.values.each do |suit| return suit if suit.key.casecmp(key) == 0 end raise ArgumentError, "No suit exists for key " + key end |
Instance Method Details
#==(suit) ⇒ Object
31 32 33 |
# File 'lib/rora/model/suit.rb', line 31 def == suit self.id == suit.id end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/rora/model/suit.rb', line 27 def to_s "Suit: id=#{@id}, key='#{@key}', value='#{@value}'" end |