class StringRandomizer::StringGenerator
Public Class Methods
new(options)
click to toggle source
# File lib/string_randomizer/string_generator.rb, line 2 def initialize(options) @string_length = options[:length] @allowed_char = options[:choose_from] @total_line = options[:lines] end
Public Instance Methods
generate_string()
click to toggle source
# File lib/string_randomizer/string_generator.rb, line 8 def generate_string return generate_random_char_line if @total_line == 1 (1..@total_line).map{|n| generate_random_char_line}.join("\n") end
Private Instance Methods
generate_random_char_line()
click to toggle source
# File lib/string_randomizer/string_generator.rb, line 15 def generate_random_char_line (0...@string_length).map { @allowed_char[rand(@allowed_char.length)] }.join end