Class Deck
In: lib/quiz1/t/solutions/Jamis Buck/lib/cipher.rb
lib/quiz1/t/solutions/Glen M. Lewis/solitaire.rb
lib/quiz1/t/solutions/Niklas Frykholm/solitaire.rb
lib/quiz1/t/solutions/Thomas Leitner/solitaire.rb
lib/quiz1/t/solutions/Bill Guindon/solitaire.rb
lib/quiz1/t/solutions/Jim Menard/solitaire_cypher.rb
lib/quiz1/t/solutions/Dennis Ranke/solitaire.rb
Parent: Object

the obligatory deck of cards.

Methods

Attributes

cards  [R] 
order  [R] 

Public Class methods

Initializes the deck with the default values

Public Instance methods

build order while adding.

Perform a count cut using the value of the bottom card. Cut the bottom card‘s value in cards off the top of the deck and reinsert them just above the bottom card.

Operation "count cut" (step 5)

does as many cuts as you give it.

Uses order to hunt for cards (Joker searches).

Return the next keystream value as a number 1-26 (not a string).

Keys the deck and returns itself.

Move a card a certain distance. Wrap around the end of the deck.

Operation "move a" (step 2)

Operation "move b" (step 3)

Return the next kestream value as a number (not a string). Keep going until we have a non-joker value.

Operation "output the found letter" (step 6)

Return the output number (not letter). Convert the top card to it‘s value and count down that many cards from the top of the deck, with the top card itself being card number one. Look at the card immediately after your count and convert it to a letter. This is the next letter in the keystream. If the output card is a joker, no letter is generated this sequence. This step does not alter the deck.

Shuffle the deck using the initialization number init and the method method. Currently there are only two methods: :fisher_yates and naive.

Returns a non-nil cut of cards from the deck.

Perform a triple cut around the two jokers. All cards above the top joker move to below the bottom joker and vice versa. The jokers and the cards between them do not move.

Operation "triple cut" (step 4)

simple, but not very efficient.

[Validate]