class PatternMatcher::Matcher
Public Class Methods
match_pattern_in_text(pattern, text)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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
Private Class Methods
is_valid_regex?(pattern)
click to toggle source
# File lib/pattern_matcher/matcher.rb, line 25 def self.is_valid_regex?(pattern) !pattern.nil? end
is_valid_regex_string?(string)
click to toggle source
# File lib/pattern_matcher/matcher.rb, line 21 def self.is_valid_regex_string?(string) !string.nil? && !string.empty? end
is_valid_text?(text)
click to toggle source
# File lib/pattern_matcher/matcher.rb, line 29 def self.is_valid_text?(text) !text.nil? && !text.empty? end