Class: Solr::Request::Mlt

Inherits:
Base
  • Object
show all
Defined in:
lib/solr/request/mlt.rb

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Mlt

Returns a new instance of Mlt.



3
4
5
# File 'lib/solr/request/mlt.rb', line 3

def initialize(params)
  @params = params
end

Instance Method Details

#content_typeObject



15
16
17
# File 'lib/solr/request/mlt.rb', line 15

def content_type
  'application/x-www-form-urlencoded; charset=utf-8'
end

#handlerObject



11
12
13
# File 'lib/solr/request/mlt.rb', line 11

def handler
  'mlt'
end

#response_formatObject



7
8
9
# File 'lib/solr/request/mlt.rb', line 7

def response_format
  :ruby
end

#to_hashObject



19
20
21
# File 'lib/solr/request/mlt.rb', line 19

def to_hash
  @params.update(:wt => 'ruby')
end

#to_sObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/solr/request/mlt.rb', line 23

def to_s
  raw_params = self.to_hash

  http_params = []
  raw_params.each do |key,value|
    if value.respond_to?(:each) && !value.is_a?(String)
      value.each { |v| http_params << "#{key}=#{ERB::Util::url_encode(v)}" unless v.nil?}
    else
      http_params << "#{key}=#{ERB::Util::url_encode(value)}" unless value.nil?
    end
  end

  http_params.join("&")
end