Class: Eson::Search::GeoBoundingBox

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Filter

included, #method_missing

Constructor Details

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

Returns a new instance of GeoBoundingBox.



11
12
13
14
# File 'lib/eson/search/geo_bounding_box.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_bounding_box.rb', line 9

def field
  @field
end

#optionsObject

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#bottom_right(location, *args) ⇒ Object



23
24
25
26
27
28
# File 'lib/eson/search/geo_bounding_box.rb', line 23

def bottom_right(location, *args)
  unless args.empty?
    location + args
  end
  options[:bottom_right] = location
end

#geo_bounding_box { ... } ⇒ self

Generates a ‘geo_bounding_box` filter in a filter context.

Yields:

  • the block containing further options and subfilters

Returns:

  • (self)

    the generated facet



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

short_name :geo_bounding_box

#to_query_hashObject



30
31
32
# File 'lib/eson/search/geo_bounding_box.rb', line 30

def to_query_hash
  { name => {field => options } }
end

#top_left(location, *args) ⇒ Object



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

def top_left(location, *args)
  unless args.empty?
    location + args
  end
  options[:top_left] = location
end