Class: Couchbase::SearchSort::SearchSortGeoDistance

Inherits:
Couchbase::SearchSort show all
Defined in:
lib/couchbase/search_options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Couchbase::SearchSort

field, geo_distance, id, score

Constructor Details

#initialize(field, longitude, latitude) {|| ... } ⇒ SearchSortGeoDistance

Returns a new instance of SearchSortGeoDistance.

Parameters:

  • field (String)

    field name

  • longitude (Float)
  • latitude (Float)

Yield Parameters:



1247
1248
1249
1250
1251
1252
1253
# File 'lib/couchbase/search_options.rb', line 1247

def initialize(field, longitude, latitude)
  super()
  @field = field
  @longitude = longitude
  @latitude = latitude
  yield self if block_given?
end

Instance Attribute Details

#descBoolean

Returns if descending order should be applied.

Returns:

  • (Boolean)

    if descending order should be applied



1232
1233
1234
# File 'lib/couchbase/search_options.rb', line 1232

def desc
  @desc
end

#fieldString (readonly)

Returns name of the field to sort by.

Returns:

  • (String)

    name of the field to sort by



1229
1230
1231
# File 'lib/couchbase/search_options.rb', line 1229

def field
  @field
end

#latitudeFloat (readonly)

Returns:

  • (Float)


1238
1239
1240
# File 'lib/couchbase/search_options.rb', line 1238

def latitude
  @latitude
end

#longitudeFloat (readonly)

Returns:

  • (Float)


1235
1236
1237
# File 'lib/couchbase/search_options.rb', line 1235

def longitude
  @longitude
end

#unit:meters, ...

Returns:

  • (:meters, :miles, :centimeters, :millimeters, :kilometers, :nauticalmiles, :feet, :yards, :inch)


1241
1242
1243
# File 'lib/couchbase/search_options.rb', line 1241

def unit
  @unit
end

Instance Method Details

#to_json(*args) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



1256
1257
1258
# File 'lib/couchbase/search_options.rb', line 1256

def to_json(*args)
  {by: :geo_distance, field: field, desc: desc, location: [longitude, latitude], unit: unit}.to_json(*args)
end