Class: Spatula::Search
- Inherits:
-
Object
- Object
- Spatula::Search
- Defined in:
- lib/spatula/search.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(query, start = 0, count = 10) ⇒ Search
constructor
A new instance of Search.
- #run ⇒ Object
Constructor Details
#initialize(query, start = 0, count = 10) ⇒ Search
Returns a new instance of Search.
8 9 10 11 12 |
# File 'lib/spatula/search.rb', line 8 def initialize(query, start=0, count=10) @query = query @start = start @count = count end |
Class Method Details
.run(*args) ⇒ Object
4 5 6 |
# File 'lib/spatula/search.rb', line 4 def self.run(*args) new(*args).run end |
Instance Method Details
#run ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/spatula/search.rb', line 14 def run url = URI.parse("%s/search?q=%s&start=%s&items=%s" % [BASE_URL, @query, @start, @count]) response = Net::HTTP.get(url) items = JSON.parse(response)["items"] items.each do |item| puts [item["cookbook_name"], item["cookbook_description"], item["cookbook_maintainer"]].join("\t") end end |