module RandomString::Main

Public Instance Methods

gen(pattern)
Alias for: generate
generate(pattern) click to toggle source
# File lib/random_string/main.rb, line 7
def generate(pattern)
        matched_strings = []
        unmatched_strings = []
        sample_strings.each do |sample_string|
                break if matched_strings.size == ResultCount && unmatched_strings.size == ResultCount

                if sample_string =~ pattern
                        matched_strings << sample_string if matched_strings.size < ResultCount
                else
                        unmatched_strings << sample_string if unmatched_strings.size < ResultCount
                end
        end

        {
                :matched_strings   => matched_strings,
                :unmatched_strings => unmatched_strings
        }
end
Also aliased as: gen