Class: RegexGenerator::Generator
- Inherits:
-
Object
- Object
- RegexGenerator::Generator
- Defined in:
- lib/regex_generator/generator.rb
Instance Method Summary collapse
- #generate ⇒ Regexp
-
#initialize(target, text, options = {}) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(target, text, options = {}) ⇒ Generator
Returns a new instance of Generator.
11 12 13 14 15 16 |
# File 'lib/regex_generator/generator.rb', line 11 def initialize(target, text, = {}) @text = text @target = RegexGenerator::Target.new(target) @target_str = @target.to_s = end |
Instance Method Details
#generate ⇒ Regexp
20 21 22 23 24 25 26 27 28 |
# File 'lib/regex_generator/generator.rb', line 20 def generate raise RegexGenerator::TargetNotFoundError unless @target.present?(@text) string_regex_chars = recognize_text(cut_nearest_text, ) string_patterns_array = slice_to_identicals(string_regex_chars) string_regex_str = join_patterns(string_patterns_array) Regexp.new string_regex_str end |