Class: Pontifex::KeyStream

Inherits:
Object
  • Object
show all
Defined in:
lib/pontifex/key_stream.rb

Constant Summary collapse

JA =
Card.new("ja")
JB =
Card.new("jb")

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key = Pontifex::DEFAULT_KEY) ⇒ KeyStream

Returns a new instance of KeyStream.



16
17
18
# File 'lib/pontifex/key_stream.rb', line 16

def initialize(key=Pontifex::DEFAULT_KEY)
  @deck = process_param(key)
end

Instance Attribute Details

#deckObject (readonly)

Returns the value of attribute deck.



12
13
14
# File 'lib/pontifex/key_stream.rb', line 12

def deck
  @deck
end

Instance Method Details

#letterObject



27
28
29
30
31
32
33
34
35
# File 'lib/pontifex/key_stream.rb', line 27

def letter
  count = @deck.first.to_i
  if result = @deck[count].to_c
    result
  else
    sequence!
    letter
  end
end

#sequence!Object



20
21
22
23
24
25
# File 'lib/pontifex/key_stream.rb', line 20

def sequence!
  move_down!("ja", 1)
  move_down!("jb", 2)
  triple_cut!
  count_cut!
end

#to_keyObject



37
38
39
# File 'lib/pontifex/key_stream.rb', line 37

def to_key
  @deck.map { |card| card.str }.join(",")
end