Class: RubyQuiz1::Card
- Inherits:
-
Object
- Object
- RubyQuiz1::Card
- Defined in:
- lib/ruby_quiz_1/card.rb
Instance Attribute Summary collapse
-
#suit ⇒ Object
readonly
Returns the value of attribute suit.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(value, suit) ⇒ Card
constructor
A new instance of Card.
- #total_value ⇒ Object
Constructor Details
#initialize(value, suit) ⇒ Card
Returns a new instance of Card.
6 7 8 9 |
# File 'lib/ruby_quiz_1/card.rb', line 6 def initialize(value, suit) raise ArgumentError unless (1..13).to_a.include? value @value, @suit = value, suit end |
Instance Attribute Details
#suit ⇒ Object (readonly)
Returns the value of attribute suit.
4 5 6 |
# File 'lib/ruby_quiz_1/card.rb', line 4 def suit @suit end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
4 5 6 |
# File 'lib/ruby_quiz_1/card.rb', line 4 def value @value end |
Instance Method Details
#total_value ⇒ Object
11 12 13 |
# File 'lib/ruby_quiz_1/card.rb', line 11 def total_value value + suit.value end |