Class: Tankard::Api::Search
- Inherits:
-
Object
- Object
- Tankard::Api::Search
- Includes:
- Enumerable, Utils::PageFinders
- Defined in:
- lib/tankard/api/search.rb
Overview
Access for the /search route on brewerydb
Instance Method Summary collapse
-
#each {|hash| ... } ⇒ Object
Calls the given block once for each result.
-
#geo_point(latitude, longitude) ⇒ self
search for berweries around a specific point.
-
#initialize(request, options = {}) ⇒ Tankard::Api::Search
constructor
Initializes a new object.
-
#page(number) ⇒ self
Page number to request.
-
#params(options = {}) ⇒ self
Additional parameters to send with the request.
-
#query(search_query) ⇒ self
Query to search for.
-
#type(search_type) ⇒ self
Type of search to perform.
-
#upc(upc_code) ⇒ self
search for a specific upc.
Constructor Details
#initialize(request, options = {}) ⇒ Tankard::Api::Search
Initializes a new object
20 21 22 23 |
# File 'lib/tankard/api/search.rb', line 20 def initialize(request, = {}) @http_client = request @http_request_parameters = Hashie::Mash.new() end |
Instance Method Details
#each {|hash| ... } ⇒ Object
Calls the given block once for each result
33 34 35 36 |
# File 'lib/tankard/api/search.rb', line 33 def each(&block) super(&block) end |
#geo_point(latitude, longitude) ⇒ self
search for berweries around a specific point. sets the endpoint to geo/point and passes lat/lng as parameters
93 94 95 96 97 98 |
# File 'lib/tankard/api/search.rb', line 93 def geo_point(latitude, longitude) @http_request_parameters.lat = latitude @http_request_parameters.lng = longitude @http_request_parameters.endpoint = 'geo/point' self end |
#page(number) ⇒ self
Page number to request
51 52 53 54 |
# File 'lib/tankard/api/search.rb', line 51 def page(number) @http_request_parameters.p = number self end |
#params(options = {}) ⇒ self
Additional parameters to send with the request
60 61 62 63 64 65 |
# File 'lib/tankard/api/search.rb', line 60 def params( = {}) .each_pair do |key, value| @http_request_parameters[key] = value end self end |
#query(search_query) ⇒ self
Query to search for
42 43 44 45 |
# File 'lib/tankard/api/search.rb', line 42 def query(search_query) @http_request_parameters.q = search_query self end |
#type(search_type) ⇒ self
Type of search to perform
71 72 73 74 |
# File 'lib/tankard/api/search.rb', line 71 def type(search_type) @http_request_parameters.type = search_type self end |
#upc(upc_code) ⇒ self
search for a specific upc. sets the endpoint to upc and passes upc_code as a parameter
81 82 83 84 85 |
# File 'lib/tankard/api/search.rb', line 81 def upc(upc_code) @http_request_parameters.code = upc_code @http_request_parameters.endpoint = 'upc' self end |