class ChefZero::Solr::Query::RegexpableQuery
Constants
- DEFAULT_FIELD
- NON_WORD_CHARACTER
- WORD_CHARACTER
Attributes
literal_string[R]
regexp[R]
regexp_string[R]
Public Class Methods
new(regexp_string, literal_string)
click to toggle source
# File lib/chef_zero/solr/query/regexpable_query.rb, line 5 def initialize(regexp_string, literal_string) @regexp_string = regexp_string # Surround the regexp with word boundaries @regexp = Regexp.new("(^|#{NON_WORD_CHARACTER})#{regexp_string}($|#{NON_WORD_CHARACTER})", true) @literal_string = literal_string end
Public Instance Methods
matches_doc?(doc)
click to toggle source
# File lib/chef_zero/solr/query/regexpable_query.rb, line 16 def matches_doc?(doc) matches_values?(doc[DEFAULT_FIELD]) end
matches_values?(values)
click to toggle source
# File lib/chef_zero/solr/query/regexpable_query.rb, line 19 def matches_values?(values) values.any? { |value| !@regexp.match(value).nil? } end