Class: RubyQuiz1::Solitaire
- Inherits:
-
Object
- Object
- RubyQuiz1::Solitaire
- Defined in:
- lib/ruby_quiz_1/solitaire.rb
Instance Attribute Summary collapse
-
#deck ⇒ Object
readonly
Returns the value of attribute deck.
Instance Method Summary collapse
-
#initialize(deck) ⇒ Solitaire
constructor
A new instance of Solitaire.
- #next_key ⇒ Object
Constructor Details
#initialize(deck) ⇒ Solitaire
Returns a new instance of Solitaire.
6 7 8 9 10 11 |
# File 'lib/ruby_quiz_1/solitaire.rb', line 6 def initialize(deck) @deck = deck jokers = deck.select { |c| c.is_a?(Joker) } raise ArgumentError, "#{jokers.size} jokers in the deck but 2 required" unless jokers.size == 2 @joker_a, @joker_b = jokers end |
Instance Attribute Details
#deck ⇒ Object (readonly)
Returns the value of attribute deck.
4 5 6 |
# File 'lib/ruby_quiz_1/solitaire.rb', line 4 def deck @deck end |
Instance Method Details
#next_key ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ruby_quiz_1/solitaire.rb', line 14 def next_key key = nil until key move_card(joker_a, 1) move_card(joker_b, 2) triple_cut count_cut key = current_letter end key end |