Class: Boolminot::Clauses::Terms
- Inherits:
-
Base
- Object
- Logica::Predicates::Base
- Base
- Boolminot::Clauses::Terms
show all
- Defined in:
- lib/boolminot/clauses/terms.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#predicate_factory
#satisfied_by?, #to_elasticsearch, #to_elasticsearch_negated, #to_raw_bool
Constructor Details
#initialize(field, values, opts = {}) ⇒ Terms
Returns a new instance of Terms.
6
7
8
9
10
|
# File 'lib/boolminot/clauses/terms.rb', line 6
def initialize(field, values, opts = {})
@field = field.to_sym
@values = values.uniq
@opts = opts
end
|
Instance Attribute Details
#field ⇒ Object
Returns the value of attribute field.
4
5
6
|
# File 'lib/boolminot/clauses/terms.rb', line 4
def field
@field
end
|
#opts ⇒ Object
Returns the value of attribute opts.
4
5
6
|
# File 'lib/boolminot/clauses/terms.rb', line 4
def opts
@opts
end
|
#values ⇒ Object
Returns the value of attribute values.
4
5
6
|
# File 'lib/boolminot/clauses/terms.rb', line 4
def values
@values
end
|
Instance Method Details
#generalization_of_terms?(terms_clause) ⇒ Boolean
31
32
33
34
|
# File 'lib/boolminot/clauses/terms.rb', line 31
def generalization_of_terms?(terms_clause)
return super unless opts.empty? && terms_clause.opts.empty?
field == terms_clause.field && terms_clause.values.all? { |v| values.include?(v) }
end
|
#or(other) ⇒ Object
12
13
14
|
# File 'lib/boolminot/clauses/terms.rb', line 12
def or(other)
other.or_with_terms(self)
end
|
#or_with_disjunction(disjunction) ⇒ Object
23
24
25
|
# File 'lib/boolminot/clauses/terms.rb', line 23
def or_with_disjunction(disjunction)
disjunction.or_with_terms(self, argument_first: false)
end
|
#or_with_terms(terms_clause) ⇒ Object
16
17
18
19
20
21
|
# File 'lib/boolminot/clauses/terms.rb', line 16
def or_with_terms(terms_clause)
return super unless opts.empty? && terms_clause.opts.empty?
return super unless field == terms_clause.field
clause_factory.terms(field, terms_clause.values + values)
end
|
#specialization_of?(other) ⇒ Boolean
27
28
29
|
# File 'lib/boolminot/clauses/terms.rb', line 27
def specialization_of?(other)
other.generalization_of_terms?(self)
end
|
#terms_with_field?(some_field) ⇒ Boolean
36
37
38
|
# File 'lib/boolminot/clauses/terms.rb', line 36
def terms_with_field?(some_field)
some_field == field
end
|