Class: BreweryDb
Overview
BreweryDb.configure do |config|
config.apikey = 'c0189f0299dd9333669a845b5ec14'
end
Constant Summary collapse
- @@apikey =
nil
Class Method Summary collapse
- .apikey ⇒ Object
- .apikey=(apikey) ⇒ Object
- .beer(id, options = {}) ⇒ Object
- .beers(options = {}) ⇒ Object
- .breweries(options = {}) ⇒ Object
- .brewery(id, options = {}) ⇒ Object
- .categories(options = {}) ⇒ Object
- .category(id, options = {}) ⇒ Object
- .configure {|_self| ... } ⇒ Object
- .glass(id, options = {}) ⇒ Object
- .glassware(options = {}) ⇒ Object
- .search(options = {}) ⇒ Object
- .style(id, options = {}) ⇒ Object
- .styles(options = {}) ⇒ Object
Class Method Details
.apikey ⇒ Object
116 117 118 |
# File 'lib/brewerydb.rb', line 116 def self.apikey @@apikey end |
.apikey=(apikey) ⇒ Object
120 121 122 |
# File 'lib/brewerydb.rb', line 120 def self.apikey=(apikey) @@apikey = apikey end |
.beer(id, options = {}) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/brewerydb.rb', line 53 def self.beer(id, ={}) .merge!({ :apikey => apikey }) response = get("/beers/#{id}", :query => ) Hashie::Mash.new(response['beers']['beer']) if response.code == 200 end |
.beers(options = {}) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/brewerydb.rb', line 44 def self.beers(={}) .merge!({ :apikey => apikey }) response = get("/beers", :query => ) Hashie::Mash.new(response['beers']) if response.code == 200 end |
.breweries(options = {}) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/brewerydb.rb', line 26 def self.breweries(={}) .merge!({ :apikey => apikey }) response = get("/breweries", :query => ) Hashie::Mash.new(response['breweries']) if response.code == 200 end |
.brewery(id, options = {}) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/brewerydb.rb', line 35 def self.brewery(id, ={}) .merge!({ :apikey => apikey }) response = get("/breweries/#{id}", :query => ) Hashie::Mash.new(response['breweries']['brewery']) if response.code == 200 end |
.categories(options = {}) ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/brewerydb.rb', line 80 def self.categories(={}) .merge!({ :apikey => apikey }) response = get("/categories", :query => ) Hashie::Mash.new(response['categories']) if response.code == 200 end |
.category(id, options = {}) ⇒ Object
89 90 91 92 93 94 95 96 |
# File 'lib/brewerydb.rb', line 89 def self.category(id, ={}) .merge!({ :apikey => apikey }) response = get("/categories/#{id}", :query => ) Hashie::Mash.new(response['categories']['category']) if response.code == 200 end |
.configure {|_self| ... } ⇒ Object
124 125 126 |
# File 'lib/brewerydb.rb', line 124 def self.configure yield self end |
.glass(id, options = {}) ⇒ Object
107 108 109 110 111 112 113 114 |
# File 'lib/brewerydb.rb', line 107 def self.glass(id, ={}) .merge!({ :apikey => apikey }) response = get("/glassware/#{id}", :query => ) Hashie::Mash.new(response['glassware']['glass']) if response.code == 200 end |
.glassware(options = {}) ⇒ Object
98 99 100 101 102 103 104 105 |
# File 'lib/brewerydb.rb', line 98 def self.glassware(={}) .merge!({ :apikey => apikey }) response = get("/glassware", :query => ) Hashie::Mash.new(response['glassware']) if response.code == 200 end |
.search(options = {}) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/brewerydb.rb', line 17 def self.search(={}) .merge!({ :apikey => apikey }) response = get("/search", :query => ) Hashie::Mash.new(response['results']) if response.code == 200 end |
.style(id, options = {}) ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/brewerydb.rb', line 71 def self.style(id, ={}) .merge!({ :apikey => apikey }) response = get("/styles/#{id}", :query => ) Hashie::Mash.new(response['styles']['style']) if response.code == 200 end |
.styles(options = {}) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/brewerydb.rb', line 62 def self.styles(={}) .merge!({ :apikey => apikey }) response = get("/styles", :query => ) Hashie::Mash.new(response['styles']) if response.code == 200 end |