Module: Mongoid::Extensions::Symbol::Inflections
- Defined in:
- lib/mongoid/geo/inflections.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#geoNear ⇒ Object
(also: #geo_near)
$nearSphere $centerSphere nearMax - { $near : [50,50] , $maxDistance : 5 } withinBox - : {“$box” : box withinCenter - : {“$center” : [center, radius]}}).
- #nearMax(*calcs) ⇒ Object (also: #near_max)
- #nearSphere ⇒ Object (also: #near_sphere)
- #withinBox(calc = :flat) ⇒ Object (also: #within_box)
- #withinCenter(calc = :flat) ⇒ Object (also: #within_center)
Instance Method Details
#geoNear ⇒ Object Also known as: geo_near
$nearSphere $centerSphere
nearMax
-
{ $near : [50,50] , $maxDistance : 5 }
withinBox
-
: {“$box” : box
withinCenter
-
: {“$center” : [center, radius]}})
15 16 17 |
# File 'lib/mongoid/geo/inflections.rb', line 15 def geoNear Criterion::Complex.new(:operator => 'geoNearSphere', :key => self) end |
#nearMax(*calcs) ⇒ Object Also known as: near_max
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/mongoid/geo/inflections.rb', line 27 def nearMax *calcs calcs = (!calcs || calcs.empty?) ? [:flat] : calcs case calcs.size when 1 Criterion::TwinOperators.new(:op_a => get_op(calcs.first, 'near'), :op_b => get_op(calcs.first, 'maxDistance'), :key => self) when 2 Criterion::TwinOperators.new(:op_a => get_op(calcs.first, 'near'), :op_b => get_op(calcs.last, 'maxDistance'), :key => self) else raise "method nearMax takes one or two symbols as arguments, each symbol must be either :flat or :sphere" end end |
#nearSphere ⇒ Object Also known as: near_sphere
20 21 22 23 24 |
# File 'lib/mongoid/geo/inflections.rb', line 20 def nearSphere Mongoid::Geo.spherical_mode do Criterion::Complex.new(:operator => 'nearSphere', :key => self) end end |
#withinBox(calc = :flat) ⇒ Object Also known as: within_box
40 41 42 |
# File 'lib/mongoid/geo/inflections.rb', line 40 def withinBox calc = :flat Criterion::OuterOperator.new(:outer_op => 'within', :operator => get_op(calc, 'box'), :key => self) end |
#withinCenter(calc = :flat) ⇒ Object Also known as: within_center
45 46 47 |
# File 'lib/mongoid/geo/inflections.rb', line 45 def withinCenter calc = :flat Criterion::OuterOperator.new(:outer_op => 'within', :operator => get_op(calc, 'center'), :key => self) end |