Module: BeerDB

Includes:
HTTParty
Defined in:
lib/beerdb_api.rb

Class Method Summary collapse

Class Method Details

.beer_info(name) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/beerdb_api.rb', line 16

def self.beer_info(name)
  beer_array = []
  beer_object = self.get("/beers?name=#{name}&key=#{@api_key}").to_json
  parsed_response = JSON.parse(beer_object, object_class: OpenStruct)
  parsed_response = parsed_response.data[0]
  beer_array << parsed_response.name << parsed_response.description << parsed_response.abv
end

.set_api_key(api_key) ⇒ Object



12
13
14
# File 'lib/beerdb_api.rb', line 12

def self.set_api_key(api_key)
  @api_key << api_key
end