Class: ElasticsearchQueryParser::Sentence
- Inherits:
-
Object
- Object
- ElasticsearchQueryParser::Sentence
- Defined in:
- lib/elasticsearch_query_parser/sentence.rb
Overview
Transform user query to ‘Left to Right` expression for parser usage
Constant Summary collapse
- WORD_SPLITTER_REGEX =
Split by whitespace, but not split words in quotes
/(?:'(?:\\.|[^'])*'|[^' ])+/.freeze
Instance Method Summary collapse
-
#initialize(sentence) ⇒ Sentence
constructor
Initialize with user input.
-
#to_s ⇒ Object
Return valid for parser usage user input Example: >> ElasticsearchQueryParser.new(“(London AND Madrid) OR Paris”).to_s => “Paris OR ( Madrid AND London )”.
Constructor Details
#initialize(sentence) ⇒ Sentence
Initialize with user input
11 12 13 |
# File 'lib/elasticsearch_query_parser/sentence.rb', line 11 def initialize(sentence) @sentence = sentence end |
Instance Method Details
#to_s ⇒ Object
Return valid for parser usage user input Example:
>> ElasticsearchQueryParser.new("(London AND Madrid) OR Paris").to_s
=> "Paris OR ( Madrid AND London )"
19 20 21 |
# File 'lib/elasticsearch_query_parser/sentence.rb', line 19 def to_s left_to_right? ? sentence : revert_left_to_right end |