Class: XTF::Search::Element::And

Inherits:
Clause show all
Defined in:
lib/xtf/search/element/and.rb

Constant Summary

Constants inherited from Clause

Clause::VALID_TAG_NAMES

Constants inherited from Base

Base::BASE_ATTRIBUTE_KEYS

Instance Attribute Summary

Attributes inherited from Clause

#content, #section_type, #term

Attributes inherited from Base

#tag_name

Instance Method Summary collapse

Methods inherited from Clause

create, #to_xml, #to_xml_node

Methods inherited from Base

attribute_keys, #attributes

Constructor Details

#initialize(*args) ⇒ And

Returns a new instance of And.

Raises:

  • (ArgumentError)


4
5
6
7
8
9
10
11
# File 'lib/xtf/search/element/and.rb', line 4

def initialize(*args)
  @tag_name = "and"
  params = args[0] || {}
  raise ArgumentError, "Provide :field or :fields, but not both" if params.key?(:field) && params.key?(:fields)
  raise ArgumentError, ":fields requires :slop" if params.key?(:fields) && !params.key?(:slop)
  raise ArgumentError, ":slop requires :fields" if params.key?(:slop) && !params.key?(:fields)
  super
end