Class: VGen::StringGen
- Inherits:
-
Object
- Object
- VGen::StringGen
- Defined in:
- lib/v_gen/string_gen.rb
Instance Attribute Summary collapse
-
#char_gen ⇒ Object
readonly
Returns the value of attribute char_gen.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(char_gen: LetterGen.new, length: (4..9), except: []) ⇒ StringGen
constructor
A new instance of StringGen.
Constructor Details
#initialize(char_gen: LetterGen.new, length: (4..9), except: []) ⇒ StringGen
Returns a new instance of StringGen.
6 7 8 9 10 11 12 13 14 |
# File 'lib/v_gen/string_gen.rb', line 6 def initialize( char_gen: LetterGen.new, length: (4..9), except: [] ) @length = length @char_gen = char_gen @except = except end |
Instance Attribute Details
#char_gen ⇒ Object (readonly)
Returns the value of attribute char_gen.
5 6 7 |
# File 'lib/v_gen/string_gen.rb', line 5 def char_gen @char_gen end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/v_gen/string_gen.rb', line 16 def call() loop do word = Array.new( word_length, @char_gen ).map(&:call).join return word unless @except.include? word end end |