Class: XTF::Search::Element::Near

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

Direct Known Subclasses

OrNear

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) ⇒ Near

slop is required. You can pass it in as the first argument or in the attributes Hash with the key :slop.

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
14
15
16
# File 'lib/xtf/search/element/near.rb', line 6

def initialize(*args)
  @tag_name = "near"
  @slop = args.shift.to_s if args[0].is_a?(String) || args[0].is_a?(Integer)
  params = args[0] || {}
  raise ArgumentError, "supply slop as first argument or as attribute of Hash, but not both!" if @slop && params.key?(:slop)

  @slop = params.delete(:slop) unless @slop
  raise ArgumentError, "slop is required." unless @slop

  super
end