Class: ElasticsearchQuery::FilterFormatter::Range

Inherits:
Base
  • Object
show all
Defined in:
lib/elasticsearch_query/filter_formatter/range.rb

Constant Summary collapse

INFINITY =
'inf'.freeze
NEGATIVE_INFINITY =
'neginf'.freeze

Class Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from ElasticsearchQuery::FilterFormatter::Base

Class Attribute Details

.parserObject

Returns the value of attribute parser.



45
46
47
# File 'lib/elasticsearch_query/filter_formatter/range.rb', line 45

def parser
  @parser
end

Instance Method Details

#to_hashObject



7
8
9
10
11
12
13
14
15
16
# File 'lib/elasticsearch_query/filter_formatter/range.rb', line 7

def to_hash
  return nil if all_the_values?

  range = {}.tap do |range|
    range[ :gte ] = beginning unless negative_infinity?( beginning )
    range[ :lt ]  = ending    unless infinity?( ending )
  end

  { range: { @name => range } }
end