Class: PatternMatcher::Matcher
- Inherits:
-
Object
- Object
- PatternMatcher::Matcher
- Defined in:
- lib/pattern_matcher/matcher.rb
Class Method Summary collapse
- .match_pattern_in_text(pattern, text) ⇒ Object
- .match_regex_in_text(regex, text) ⇒ Object
- .string_to_regex(string) ⇒ Object
Class Method Details
.match_pattern_in_text(pattern, text) ⇒ Object
11 12 13 |
# File 'lib/pattern_matcher/matcher.rb', line 11 def self.match_pattern_in_text(pattern, text) return match_regex_in_text(pattern.regex, text) if pattern && is_valid_text?(text) end |
.match_regex_in_text(regex, text) ⇒ Object
15 16 17 |
# File 'lib/pattern_matcher/matcher.rb', line 15 def self.match_regex_in_text(regex, text) return regex.match text if is_valid_regex?(regex) && is_valid_text?(text) end |
.string_to_regex(string) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/pattern_matcher/matcher.rb', line 4 def self.string_to_regex(string) begin Regexp.new string if is_valid_regex_string?(string) rescue end end |