Class: Eson::Search::GeoDistance

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

Instance Attribute Summary collapse

Attributes included from Facet

#args, #scope_name

Instance Method Summary collapse

Methods included from Facet

included, #method_missing, #param, #scope

Methods included from Filter

included, #method_missing

Constructor Details

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

Returns a new instance of GeoDistance.



13
14
15
16
# File 'lib/eson/search/geo_distance.rb', line 13

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::Facet

Instance Attribute Details

#fieldObject

Returns the value of attribute field.



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

def field
  @field
end

#optionsObject

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#geo_distance { ... } ⇒ self #geo_distance { ... } ⇒ self

Overloads:

  • #geo_distance { ... } ⇒ self

    Generates a ‘geo_distance` filter in a filter context.

    Yields:

    • the block containing further options and subfilters

    Returns:

    • (self)

      the generated facet

  • #geo_distance { ... } ⇒ self

    Generates a ‘geo_distance` facet in a facets context.

    Yields:

    • the block describing further options

    Returns:

    • (self)

      the generated facet



9
# File 'lib/eson/search/geo_distance.rb', line 9

short_name :geo_distance

#lat(lat) ⇒ Object



18
19
20
# File 'lib/eson/search/geo_distance.rb', line 18

def lat(lat)
  @lat = lat
end

#lon(lon) ⇒ Object



22
23
24
# File 'lib/eson/search/geo_distance.rb', line 22

def lon(lon)
  @lon = lon
end

#to_query_hashObject



26
27
28
# File 'lib/eson/search/geo_distance.rb', line 26

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