Class: Qiita::Elasticsearch::Token
- Inherits:
-
Object
- Object
- Qiita::Elasticsearch::Token
- Defined in:
- lib/qiita/elasticsearch/token.rb
Instance Attribute Summary collapse
-
#field_name ⇒ Object
readonly
Returns the value of attribute field_name.
-
#term ⇒ Object
readonly
Returns the value of attribute term.
Instance Method Summary collapse
-
#initialize(field_name: nil, minus: nil, quoted: nil, term: nil, token_string: nil) ⇒ Token
constructor
A new instance of Token.
- #must? ⇒ Boolean
- #must_not? ⇒ Boolean
-
#negative? ⇒ true, false
True if this token is for negative filter.
-
#or? ⇒ true, false
This.
-
#positive? ⇒ true, false
Opposite of #negative?.
-
#quoted? ⇒ true, false
True if this token is for phrase matching.
- #should? ⇒ Boolean
Constructor Details
#initialize(field_name: nil, minus: nil, quoted: nil, term: nil, token_string: nil) ⇒ Token
Returns a new instance of Token.
6 7 8 9 10 11 12 |
# File 'lib/qiita/elasticsearch/token.rb', line 6 def initialize(field_name: nil, minus: nil, quoted: nil, term: nil, token_string: nil) @field_name = field_name @minus = minus @quoted = quoted @term = term @token_string = token_string end |
Instance Attribute Details
#field_name ⇒ Object (readonly)
Returns the value of attribute field_name.
4 5 6 |
# File 'lib/qiita/elasticsearch/token.rb', line 4 def field_name @field_name end |
#term ⇒ Object (readonly)
Returns the value of attribute term.
4 5 6 |
# File 'lib/qiita/elasticsearch/token.rb', line 4 def term @term end |
Instance Method Details
#must? ⇒ Boolean
14 15 16 |
# File 'lib/qiita/elasticsearch/token.rb', line 14 def must? !field_name.nil? end |
#must_not? ⇒ Boolean
18 19 20 |
# File 'lib/qiita/elasticsearch/token.rb', line 18 def must_not? negative? end |
#negative? ⇒ true, false
Note:
‘Ruby -Perl` ^^^^^ This
Returns True if this token is for negative filter.
26 27 28 |
# File 'lib/qiita/elasticsearch/token.rb', line 26 def negative? !positive? end |
#or? ⇒ true, false
Note:
‘Ruby OR Perl` ^^
This
34 35 36 |
# File 'lib/qiita/elasticsearch/token.rb', line 34 def or? @token_string.downcase == "or" end |
#positive? ⇒ true, false
Returns Opposite of #negative?.
39 40 41 |
# File 'lib/qiita/elasticsearch/token.rb', line 39 def positive? @minus.nil? end |
#quoted? ⇒ true, false
Note:
‘Express OR “Ruby on Rails”` ^^^^^^^^^^^^^^^
This
Returns True if this token is for phrase matching.
47 48 49 |
# File 'lib/qiita/elasticsearch/token.rb', line 47 def quoted? !!@quoted end |
#should? ⇒ Boolean
51 52 53 |
# File 'lib/qiita/elasticsearch/token.rb', line 51 def should? !must? && !must_not? end |