Class: Elasticband::Filter::Near

Inherits:
Elasticband::Filter show all
Defined in:
lib/elasticband/filter/near.rb

Constant Summary

Constants inherited from Elasticband::Filter

PARSE_FILTERS

Instance Attribute Summary collapse

Attributes inherited from Elasticband::Filter

#options

Instance Method Summary collapse

Methods inherited from Elasticband::Filter

parse, #parse

Constructor Details

#initialize(on: :location, latitude: nil, longitude: nil, distance: '100km', type: :arc) ⇒ Near

Returns a new instance of Near.



6
7
8
9
10
11
12
# File 'lib/elasticband/filter/near.rb', line 6

def initialize(on: :location, latitude: nil, longitude: nil, distance: '100km', type: :arc)
  self.on = on
  self.latitude = latitude
  self.longitude = longitude
  self.distance = distance
  self.type = type
end

Instance Attribute Details

#distanceObject

Returns the value of attribute distance.



4
5
6
# File 'lib/elasticband/filter/near.rb', line 4

def distance
  @distance
end

#latitudeObject

Returns the value of attribute latitude.



4
5
6
# File 'lib/elasticband/filter/near.rb', line 4

def latitude
  @latitude
end

#longitudeObject

Returns the value of attribute longitude.



4
5
6
# File 'lib/elasticband/filter/near.rb', line 4

def longitude
  @longitude
end

#onObject

Returns the value of attribute on.



4
5
6
# File 'lib/elasticband/filter/near.rb', line 4

def on
  @on
end

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/elasticband/filter/near.rb', line 4

def type
  @type
end

Instance Method Details

#to_hObject



14
15
16
17
18
19
20
21
22
# File 'lib/elasticband/filter/near.rb', line 14

def to_h
  {
    geo_distance: {
      on => { lat: latitude, lon: longitude },
      distance: distance,
      distance_type: type
    }
  }
end