class Boolminot::Clauses::Terms
Attributes
field[R]
opts[R]
values[R]
Public Class Methods
new(field, values, opts = {})
click to toggle source
# File lib/boolminot/clauses/terms.rb, line 6 def initialize(field, values, opts = {}) @field = field.to_sym @values = values.uniq @opts = opts end
Public Instance Methods
generalization_of_terms?(terms_clause)
click to toggle source
Calls superclass method
# 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)
click to toggle source
# File lib/boolminot/clauses/terms.rb, line 12 def or(other) other.or_with_terms(self) end
or_with_disjunction(disjunction)
click to toggle source
# 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)
click to toggle source
Calls superclass method
# 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)
click to toggle source
# File lib/boolminot/clauses/terms.rb, line 27 def specialization_of?(other) other.generalization_of_terms?(self) end
terms_with_field?(some_field)
click to toggle source
# File lib/boolminot/clauses/terms.rb, line 36 def terms_with_field?(some_field) some_field == field end
Private Instance Methods
body()
click to toggle source
# File lib/boolminot/clauses/terms.rb, line 46 def body { field => value_or_values } end
term?()
click to toggle source
# File lib/boolminot/clauses/terms.rb, line 54 def term? values.size == 1 end
type()
click to toggle source
Calls superclass method
Boolminot::Clauses::Base::InstanceMethods#type
# File lib/boolminot/clauses/terms.rb, line 42 def type term? ? :term : super end
value_or_values()
click to toggle source
# File lib/boolminot/clauses/terms.rb, line 50 def value_or_values term? ? values.first : values end