Sha256: 9b4640fde853e03a71b08696d4f5590815ced85d54ab51d56a626e6b387631b3
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
module HealthyHungerApi class Recipes @@all = [] def self.all @@all ||= load_recipes end def self.load_recipes(id) @recipes = API.get_recipes(id) @@all = self.create_new_recipe(@recipes) end def self.create_new_recipe(recipes) recipes.map do |recipe_hash| self.new(recipe_hash) end end attr_accessor :extended_ingredients, :instructions def initialize (attributes = {}) attributes.each do |attribute_name, attribute_value| self.send("#{attribute_name}=", attribute_value) if self.respond_to?("#{attribute_name}=") end end def self.recipe_instructions puts "Instructions:" puts @recipes["instructions"].gsub(/<\/?[a-z]+>/, "").gsub(/<a href="[a-zA-Z0-9\/:\.\-\+]+">/, "") end def self.recipe_ingredients puts "Ingredients:" @recipes["extendedIngredients"].each do | ingredient | puts "#{ingredient["amount"]} - #{ingredient["unit"]} #{ingredient["name"]}".gsub(/<\/?[a-z]+>/, "").gsub(/<a href="[a-zA-Z0-9\/:\.\-\+]+">/, "") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
Healthy_hunger_api-0.2.0 | lib/Healthy_hunger_api/recipes.rb |