Class: Echo::Search

Inherits:
API show all
Includes:
HTTParty
Defined in:
lib/echor/search.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Search

Returns a new instance of Search.



6
7
8
9
10
# File 'lib/echor/search.rb', line 6

def initialize(options={})      
  self.class.class_eval do        
    base_uri Echo.endpoint
  end
end

Instance Method Details

#build_query(options) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
18
19
20
21
# File 'lib/echor/search.rb', line 14

def build_query(options)
  raise ArgumentError unless options[:q]      
  raise ArgumentError unless Echo.user
  
  options[:appkey] = Echo.user
  
  "/search?#{options.to_query}"
end

#fetch(options = {}) ⇒ Object



23
24
25
# File 'lib/echor/search.rb', line 23

def fetch(options={})
  self.class.get(build_query(options))
end