Class: CharPool
- Inherits:
-
Object
- Object
- CharPool
- Defined in:
- lib/char_pool.rb,
lib/char_pool/version.rb
Constant Summary collapse
- VERSION =
"1.0.0"
Instance Method Summary collapse
- #index(string) ⇒ Object
- #index_at(number) ⇒ Object
-
#initialize(char_pool) ⇒ CharPool
constructor
A new instance of CharPool.
- #next ⇒ Object
- #print ⇒ Object
- #start(current = @char_pool.first) ⇒ Object
Constructor Details
#initialize(char_pool) ⇒ CharPool
Returns a new instance of CharPool.
4 5 6 |
# File 'lib/char_pool.rb', line 4 def initialize(char_pool) @char_pool = char_pool end |
Instance Method Details
#index(string) ⇒ Object
31 32 33 |
# File 'lib/char_pool.rb', line 31 def index(string) decode(string) end |
#index_at(number) ⇒ Object
26 27 28 29 |
# File 'lib/char_pool.rb', line 26 def index_at(number) encode(number).map{|i| @char_pool[i]} .join end |
#next ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/char_pool.rb', line 18 def next @current_index = 0 and return print if @current_index.nil? @current_index += 1 print end |
#print ⇒ Object
14 15 16 |
# File 'lib/char_pool.rb', line 14 def print index_at @current_index end |
#start(current = @char_pool.first) ⇒ Object
8 9 10 11 12 |
# File 'lib/char_pool.rb', line 8 def start(current = @char_pool.first) @current_index = index(current) current end |