Class: Pontifex::KeyStream
- Inherits:
-
Object
- Object
- Pontifex::KeyStream
- Defined in:
- lib/pontifex/key_stream.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#deck ⇒ Object
readonly
Returns the value of attribute deck.
Instance Method Summary collapse
-
#initialize(key = Pontifex::DEFAULT_KEY) ⇒ KeyStream
constructor
A new instance of KeyStream.
- #letter ⇒ Object
- #sequence! ⇒ Object
- #to_key ⇒ Object
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
#deck ⇒ Object (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
#letter ⇒ Object
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_key ⇒ Object
37 38 39 |
# File 'lib/pontifex/key_stream.rb', line 37 def to_key @deck.map { |card| card.str }.join(",") end |