Class: PseudoRandomValue
- Inherits:
-
Object
- Object
- PseudoRandomValue
- Defined in:
- lib/pseudo_random_value.rb
Instance Method Summary collapse
-
#initialize(arr_symbols) ⇒ PseudoRandomValue
constructor
A new instance of PseudoRandomValue.
- #new_value(token_counter) ⇒ Object
Constructor Details
#initialize(arr_symbols) ⇒ PseudoRandomValue
Returns a new instance of PseudoRandomValue.
2 3 4 5 6 7 8 9 10 |
# File 'lib/pseudo_random_value.rb', line 2 def initialize(arr_symbols) if arr_symbols.first.is_a? Array @arr_symbols = arr_symbols else arr_symbols.first.is_a? String @arr_symbols = arr_symbols.map {|s| s.split("") } end raise RuntimeError.new("Empty arr_symbols") if arr_symbols.empty? end |
Instance Method Details
#new_value(token_counter) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pseudo_random_value.rb', line 12 def new_value(token_counter) token_counter = 1 if token_counter == 0 output_value = output_value(@arr_symbols, token_counter).reverse maximum_value = maximum_value(@arr_symbols) = "Sorry, number of characters is over" raise RuntimeError.new() if token_counter >= maximum_value output_value.join end |