Class: Solitaire::Keystream

Inherits:
Object show all
Defined in:
lib/quiz1/t/solutions/Moses Hohman/cipher.rb

Constant Summary collapse

A_JOKER =
Card.joker(?A)
B_JOKER =
Card.joker(?B)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(deck = Deck.new) ⇒ Keystream

Returns a new instance of Keystream.



39
40
41
# File 'lib/quiz1/t/solutions/Moses Hohman/cipher.rb', line 39

def initialize(deck=Deck.new)
	@deck = deck
end

Class Method Details

.card_to_letter(card) ⇒ Object



47
48
49
50
# File 'lib/quiz1/t/solutions/Moses Hohman/cipher.rb', line 47

def Keystream.card_to_letter(card)
	return "" if card.is_joker?
	(card.value.offset_mod(ALPHABET_SIZE)+ASCII_OFFSET).chr
end

Instance Method Details

#keystream_letters(chunks) ⇒ Object



43
44
45
# File 'lib/quiz1/t/solutions/Moses Hohman/cipher.rb', line 43

def keystream_letters(chunks)
	chunks.collect { |chunk| (1..chunk.size).collect { next_keystream_letter }.join }
end