Class: WordGen::Generator
- Inherits:
-
Object
- Object
- WordGen::Generator
- Defined in:
- lib/word_gen/generator.rb
Instance Attribute Summary collapse
-
#character_set ⇒ Object
readonly
Returns the value of attribute character_set.
-
#word_length ⇒ Object
readonly
Returns the value of attribute word_length.
-
#writer ⇒ Object
readonly
Returns the value of attribute writer.
Instance Method Summary collapse
-
#initialize(word_length, character_set, writer = $stdout) ⇒ Generator
constructor
A new instance of Generator.
- #start ⇒ Object
Constructor Details
#initialize(word_length, character_set, writer = $stdout) ⇒ Generator
Returns a new instance of Generator.
5 6 7 8 9 10 11 |
# File 'lib/word_gen/generator.rb', line 5 def initialize word_length, character_set, writer = $stdout @word_length, @character_set, @writer = Integer(word_length), character_set.map(&:to_s), writer if @word_length < 1 fail ArgumentError, 'word_length need to be positibe' end end |
Instance Attribute Details
#character_set ⇒ Object (readonly)
Returns the value of attribute character_set.
3 4 5 |
# File 'lib/word_gen/generator.rb', line 3 def character_set @character_set end |
#word_length ⇒ Object (readonly)
Returns the value of attribute word_length.
3 4 5 |
# File 'lib/word_gen/generator.rb', line 3 def word_length @word_length end |
#writer ⇒ Object (readonly)
Returns the value of attribute writer.
3 4 5 |
# File 'lib/word_gen/generator.rb', line 3 def writer @writer end |
Instance Method Details
#start ⇒ Object
13 14 15 |
# File 'lib/word_gen/generator.rb', line 13 def start printAllKLengthRec character_set, "", character_set.size, word_length end |