Class: Tankard::Api::Beer
- Inherits:
-
Object
- Object
- Tankard::Api::Beer
- Includes:
- Enumerable, Request::Get, Utils::Find, Utils::PageFinders
- Defined in:
- lib/tankard/api/beer.rb
Overview
Access for the /beer route on brewerydb
Instance Method Summary collapse
-
#breweries ⇒ self
Sets the request to beer/:id/breweries.
-
#each {|hash| ... } ⇒ Object
Calls the given block once for each beer.
-
#events ⇒ self
Sets the request to beer/:id/events.
-
#find(id_or_array, options = {}) ⇒ Hash, Array
Find a single or multiple beers by their id.
-
#id(beer_id) ⇒ self
BeerID to query.
-
#ingredients ⇒ self
Sets the request to beer/:id/ingredients.
-
#initialize(request, options = {}) ⇒ Tankard::Api::Beer
constructor
Initialize a new object.
-
#params(options = {}) ⇒ self
Additional parameters to send with the request.
-
#social_accounts ⇒ self
Sets the request to beer/:id/socialaccounts.
-
#variations ⇒ self
Sets the request to beer/:id/variations.
Constructor Details
#initialize(request, options = {}) ⇒ Tankard::Api::Beer
Initialize a new object
23 24 25 26 |
# File 'lib/tankard/api/beer.rb', line 23 def initialize(request, ={}) @request = request @options = Hashie::Mash.new() end |
Instance Method Details
#breweries ⇒ self
Sets the request to beer/:id/breweries
59 60 61 62 |
# File 'lib/tankard/api/beer.rb', line 59 def breweries @options.endpoint = "breweries" self end |
#each {|hash| ... } ⇒ Object
Calls the given block once for each beer
|
# File 'lib/tankard/api/beer.rb', line 37
|
#events ⇒ self
Sets the request to beer/:id/events
67 68 69 70 |
# File 'lib/tankard/api/beer.rb', line 67 def events @options.endpoint = "events" self end |
#find(id_or_array, options = {}) ⇒ Hash, Array
Find a single or multiple beers by their id
|
# File 'lib/tankard/api/beer.rb', line 28
|
#id(beer_id) ⇒ self
BeerID to query
51 52 53 54 |
# File 'lib/tankard/api/beer.rb', line 51 def id(beer_id) @options.id = beer_id self end |
#ingredients ⇒ self
Sets the request to beer/:id/ingredients
75 76 77 78 |
# File 'lib/tankard/api/beer.rb', line 75 def ingredients @options.endpoint = "ingredients" self end |
#params(options = {}) ⇒ self
Additional parameters to send with the request
100 101 102 103 104 105 |
# File 'lib/tankard/api/beer.rb', line 100 def params(={}) .each_pair do |key,value| @options[key] = value end self end |
#social_accounts ⇒ self
Sets the request to beer/:id/socialaccounts
83 84 85 86 |
# File 'lib/tankard/api/beer.rb', line 83 def @options.endpoint = "socialaccounts" self end |
#variations ⇒ self
Sets the request to beer/:id/variations
91 92 93 94 |
# File 'lib/tankard/api/beer.rb', line 91 def variations @options.endpoint = "variations" self end |