class Starscope::Matcher
Constants
- MATCH_TYPES
Public Class Methods
new(query)
click to toggle source
# File lib/starscope/matcher.rb, line 5 def initialize(query) @query = query begin @regexp = Regexp.new(@query, Regexp::IGNORECASE) rescue RegexpError @regexp = nil # not a regex, oh well end end
Public Instance Methods
match(input)
click to toggle source
# File lib/starscope/matcher.rb, line 15 def match(input) if input.end_with?(@query) :literal_match elsif @regexp && @regexp.match(input) :regexp_match end end