Class: OpenSearch::OpenSearch11

Inherits:
OpenSearchBase show all
Defined in:
lib/opensearch/1.1.rb

Constant Summary collapse

Nodes =
{ 
  "url"               => { :format => {}, :requirements => [] },
  "short_name"        => { :format => "", :requirements => nil }, 
  "long_name"         => { :format => "", :requirements => nil },
  "description"       => { :format => "", :requirements => nil },
  "tags"              => { :format => "", :requirements => nil },
  "image"             => { :format => {}, :requirements => [] },
  "query"             => { :format => {}, :requirements => [] },
  "developer"         => { :format => "", :requirements => nil },
  "contact"           => { :format => "", :requirements => nil },
  "attribution"       => { :format => "", :requirements => nil },
  "syndication_right" => { :format => "", :requirements => nil },
  "adult_content"     => { :format => "", :requirements => nil },
  "language"          => { :format => "", :requirements => [] },
  "input_encoding"    => { :format => "", :requirements => [] },
  "output_encoding"   => { :format => "", :requirements => [] },
}
Pagers =
{ 
  "count"           => 20,
  "start_index"     => 1,
  "start_page"      => 1,
  "language"        => "*",
  "output_encoding" => "UTF-8",
  "input_encoding"  => "UTF-8",
}

Instance Method Summary collapse

Constructor Details

#initialize(doc) ⇒ OpenSearch11

Returns a new instance of OpenSearch11.



31
32
33
34
35
# File 'lib/opensearch/1.1.rb', line 31

def initialize(doc)
  @description = Hash.new
  @pager       = Pagers.dup
  super
end

Instance Method Details

#search(query, type = nil) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/opensearch/1.1.rb', line 37

def search(query, type = nil)
  url  = nil
  post = false
  if type.nil?
    url = @description["url"][0]["template"]
  else
    @description["url"].each do |u|
      if u["type"] == type
        url = u["template"] 
        if u["method"] =~ /post/i
          post = u["param"] 
          post = setup_query(post, query)
        end
      end
    end
  end
  raise "cannot find strict url from Description." if url.nil?
  super(url, query, post)
end