Class: Regex2String::Unmatched

Inherits:
Object
  • Object
show all
Defined in:
lib/regex2string/unmatched.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(regex, char_count) ⇒ Unmatched

Returns a new instance of Unmatched.



6
7
8
9
# File 'lib/regex2string/unmatched.rb', line 6

def initialize(regex, char_count)
  @regex = regex
  @char_count = char_count
end

Instance Attribute Details

#char_countObject

Returns the value of attribute char_count.



4
5
6
# File 'lib/regex2string/unmatched.rb', line 4

def char_count
  @char_count
end

#regexObject

Returns the value of attribute regex.



3
4
5
# File 'lib/regex2string/unmatched.rb', line 3

def regex
  @regex
end

Instance Method Details

#generate_unmatchedObject



11
12
13
14
15
16
17
18
# File 'lib/regex2string/unmatched.rb', line 11

def generate_unmatched
  rand_string = Faker::Lorem.characters(@char_count)
  while (true)
    break unless @regex.match rand_string
    rand_string = Faker::Lorem.characters(@char_count)
  end
  rand_string
end