Sha256: bfe1f701aaf6703ca016500f9db2701180640fc04d0a9e4cbcb6c89470c87e97

Contents?: true

Size: 790 Bytes

Versions: 8

Compression:

Stored size: 790 Bytes

Contents

module Sunspot
  module Query
    # 
    # This query component generates parameters for LocalSolr geo-radial
    # searches. The LocalSolr API is fairly rigid, so the Local component
    # doesn't have any options - it just takes coordinates and a radius, and
    # generates the appropriate parameters.
    #
    class Local #:nodoc:
      def initialize(coordinates, radius)
        if radius < 1
          raise ArgumentError, "LocalSolr does not seem to support a radius of less than 1 mile."
        end
        @coordinates, @radius = Util::Coordinates.new(coordinates), radius
      end

      def to_params
        {
          :qt => 'geo',
          :lat => @coordinates.lat,
          :long => @coordinates.lng,
          :radius => @radius
        }
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
sunspot-0.10.9 lib/sunspot/query/local.rb
sunspot-0.10.8 lib/sunspot/query/local.rb
nxa-sunspot-0.10.7 lib/sunspot/query/local.rb
sunspot-0.10.7 lib/sunspot/query/local.rb
sunspot-0.10.6 lib/sunspot/query/local.rb
sunspot-0.10.5 lib/sunspot/query/local.rb
sunspot-0.10.4 lib/sunspot/query/local.rb
sunspot-0.10.3 lib/sunspot/query/local.rb