Class: Elasticquery::Filters::Range

Inherits:
Base
  • Object
show all
Defined in:
lib/elasticquery/filters/range.rb

Constant Summary collapse

OPTIONS =
i(_cache execution)

Instance Method Summary collapse

Methods inherited from Base

#dup_with, #invalid?, #to_not_hash

Constructor Details

#initialize(field = nil, gte: nil, lte: nil, **options) ⇒ Range

Returns a new instance of Range.



8
9
10
11
# File 'lib/elasticquery/filters/range.rb', line 8

def initialize(field = nil, gte: nil, lte: nil, **options)
  @options = options.slice *OPTIONS
  @field, @gte, @lte = field, gte, lte
end

Instance Method Details

#to_hashObject



17
18
19
# File 'lib/elasticquery/filters/range.rb', line 17

def to_hash
  {range: range_with_options}
end

#valid?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/elasticquery/filters/range.rb', line 13

def valid?
  @gte.present? || @lte.present?
end