Class: ShuffleAlgorithm

Inherits:
Object show all
Defined in:
lib/quiz1/t/solutions/Jamis Buck/lib/cipher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#options=(value) ⇒ Object (writeonly)

Sets the attribute options

Parameters:

  • value

    the value to set the attribute options to.



215
216
217
# File 'lib/quiz1/t/solutions/Jamis Buck/lib/cipher.rb', line 215

def options=(value)
  @options = value
end

Instance Method Details

#new_deckObject



217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/quiz1/t/solutions/Jamis Buck/lib/cipher.rb', line 217

def new_deck
  deck = Deck.new
  cards = deck.to_a

  seed = ( @options[ "seed" ] || 0 ).to_i
  srand seed

  7.times { cards.sort! { rand(3)-1 } }
  deck.cards = cards

  return deck
end