Class: ChefZero::Solr::Query::Phrase

Inherits:
RegexpableQuery show all
Defined in:
lib/chef_zero/solr/query/phrase.rb

Constant Summary

Constants inherited from RegexpableQuery

RegexpableQuery::DEFAULT_FIELD, RegexpableQuery::NON_WORD_CHARACTER, RegexpableQuery::WORD_CHARACTER

Instance Attribute Summary

Attributes inherited from RegexpableQuery

#literal_string, #regexp, #regexp_string

Instance Method Summary collapse

Methods inherited from RegexpableQuery

#matches_doc?, #matches_values?

Constructor Details

#initialize(terms) ⇒ Phrase

Returns a new instance of Phrase.



7
8
9
10
11
12
13
14
15
# File 'lib/chef_zero/solr/query/phrase.rb', line 7

def initialize(terms)
  # Phrase is terms separated by whitespace
  if terms.size == 0 && terms[0].literal_string
    literal_string = terms[0].literal_string
  else
    literal_string = nil
  end
  super(terms.map(&:regexp_string).join("#{NON_WORD_CHARACTER}+"), literal_string)
end

Instance Method Details

#to_sObject



17
18
19
# File 'lib/chef_zero/solr/query/phrase.rb', line 17

def to_s
  "Phrase(\"#{@regexp_string}\")"
end