Class: Eson::Search::GeoPolygon

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Filter

included, #method_missing

Constructor Details

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

Returns a new instance of GeoPolygon.



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

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.



8
9
10
# File 'lib/eson/search/geo_polygon.rb', line 8

def field
  @field
end

#optionsObject

Returns the value of attribute options.



8
9
10
# File 'lib/eson/search/geo_polygon.rb', line 8

def options
  @options
end

Instance Method Details

#geo_polygon { ... } ⇒ self

Generates a ‘geo_polygon` filter in a filter context.

Yields:

  • the block containing further options and subfilters

Returns:

  • (self)

    the generated facet



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

short_name :geo_polygon

#point(point) ⇒ Object



23
24
25
# File 'lib/eson/search/geo_polygon.rb', line 23

def point(point)
  points << point
end

#points(points = nil) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/eson/search/geo_polygon.rb', line 15

def points(points = nil)
  if points
    @points = points
  else
    @points ||= []
  end
end

#to_query_hashObject



27
28
29
# File 'lib/eson/search/geo_polygon.rb', line 27

def to_query_hash
  { name => options.merge({ field => {:points => points} }) }
end