Class: BreweryDb

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/brewerydb.rb

Overview

BreweryDb.configure do |config|

config.apikey = 'c0189f0299dd9333669a845b5ec14'

end

Constant Summary collapse

@@apikey =
nil

Class Method Summary collapse

Class Method Details

.apikeyObject



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, options={})
  options.merge!({
    :apikey => apikey
  })
  
  response = get("/beers/#{id}", :query => options)
  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(options={})
  options.merge!({
    :apikey => apikey
  })
      
  response = get("/beers", :query => options)
  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(options={})
  options.merge!({
    :apikey => apikey
  })
      
  response = get("/breweries", :query => options)
  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, options={})
  options.merge!({
    :apikey => apikey
  })
  
  response = get("/breweries/#{id}", :query => options)
  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(options={})
  options.merge!({
    :apikey => apikey
  })
      
  response = get("/categories", :query => options)
  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, options={})
  options.merge!({
    :apikey => apikey
  })
      
  response = get("/categories/#{id}", :query => options)
  Hashie::Mash.new(response['categories']['category']) if response.code == 200
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (BreweryDb)

    the object that the method was called on



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, options={})
  options.merge!({
    :apikey => apikey
  })
      
  response = get("/glassware/#{id}", :query => options)
  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(options={})
  options.merge!({
    :apikey => apikey
  })
      
  response = get("/glassware", :query => options)
  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(options={})
  options.merge!({
    :apikey => apikey
  })
      
  response = get("/search", :query => options)
  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, options={})
  options.merge!({
    :apikey => apikey
  })
      
  response = get("/styles/#{id}", :query => options)
  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(options={})
  options.merge!({
    :apikey => apikey
  })
      
  response = get("/styles", :query => options)
  Hashie::Mash.new(response['styles']) if response.code == 200
end