Class: XTF::Search::Element::Near
- Defined in:
- lib/xtf/search/element/near.rb
Direct Known Subclasses
Constant Summary
Constants inherited from Clause
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Clause
#content, #section_type, #term
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(*args) ⇒ Near
constructor
slopis required.
Methods inherited from Clause
Methods inherited from Base
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.
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 |