Class: Eson::Search::GeoDistanceRange

Inherits:
Object
  • Object
show all
Includes:
Filter
Defined in:
lib/eson/search/geo_distance_range.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Filter

included, #method_missing

Constructor Details

#initialize(field, options = {}) ⇒ GeoDistanceRange

Returns a new instance of GeoDistanceRange.



11
12
13
14
# File 'lib/eson/search/geo_distance_range.rb', line 11

def initialize(field, options = {})
  self.field = field
  self.options = options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Eson::Search::Filter

Instance Attribute Details

#fieldObject

Returns the value of attribute field.



9
10
11
# File 'lib/eson/search/geo_distance_range.rb', line 9

def field
  @field
end

#optionsObject

Returns the value of attribute options.



9
10
11
# File 'lib/eson/search/geo_distance_range.rb', line 9

def options
  @options
end

Instance Method Details

#geo_distance_range { ... } ⇒ self

Generates a ‘geo_distance_range` filter in a filter context.

Yields:

  • the block containing further options and subfilters

Returns:

  • (self)

    the generated facet



7
# File 'lib/eson/search/geo_distance_range.rb', line 7

short_name :geo_distance_range

#lat(lat) ⇒ Object



16
17
18
# File 'lib/eson/search/geo_distance_range.rb', line 16

def lat(lat)
  @lat = lat
end

#lon(lon) ⇒ Object



20
21
22
# File 'lib/eson/search/geo_distance_range.rb', line 20

def lon(lon)
  @lon = lon
end

#to_query_hashObject



24
25
26
# File 'lib/eson/search/geo_distance_range.rb', line 24

def to_query_hash
  { name => options.merge({ field => {:lat => @lat, :lon => @lon } }) }
end