Class: Stretchy::Filters::RangeFilter

Inherits:
Base
  • Object
show all
Defined in:
lib/stretchy/filters/range_filter.rb

Constant Summary

Constants included from Utils::Contract

Utils::Contract::ASSERTIONS, Utils::Contract::DECAY_FUNCTIONS, Utils::Contract::DISTANCE_FORMAT

Instance Method Summary collapse

Methods included from Utils::Contract

included, #require_one, #validate!

Constructor Details

#initialize(options = {}) ⇒ RangeFilter

Returns a new instance of RangeFilter.



11
12
13
14
15
# File 'lib/stretchy/filters/range_filter.rb', line 11

def initialize(options = {})
  @field = options[:field]
  @range = options[:stretchy_range] || Stretchy::Types::Range.new(options)
  validate!
end

Instance Method Details

#to_searchObject



17
18
19
20
21
22
23
# File 'lib/stretchy/filters/range_filter.rb', line 17

def to_search
  {
    range: {
      @field => @range.to_search
    }
  }
end