Class: Daedal::Filters::RangeFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/daedal/filters/range_filter.rb

Instance Method Summary collapse

Methods inherited from Filter

#to_json

Constructor Details

#initialize(options = {}) ⇒ RangeFilter

Returns a new instance of RangeFilter.



15
16
17
18
19
20
# File 'lib/daedal/filters/range_filter.rb', line 15

def initialize(options={})
  super options
  unless !gte.nil? or !gt.nil? or !lt.nil? or !lte.nil?
    raise "Must give at least one of gte, gt, lt, or lte"
  end
end

Instance Method Details

#to_hashObject



22
23
24
# File 'lib/daedal/filters/range_filter.rb', line 22

def to_hash
  {range: {field => {gte: gte, lte: lte, lt: lt, gt: gt}.select {|k,v| !v.nil?}}}
end