class Recipe
Attributes
directions[RW]
ingredients[RW]
name[RW]
url[RW]
Public Class Methods
create()
click to toggle source
# File lib/daily_recipes/recipe.rb, line 14 def self.create doc = Nokogiri::HTML(open("http://pinchofyum.com/recipes")) doc.css("article.post-summary").each do |tile| recipe = self.new recipe.name = tile.css(".caption").text.strip recipe.url = tile.css(".block-link").attribute("href").value @@recipes << recipe end end
new(name = nil, url = nil)
click to toggle source
# File lib/daily_recipes/recipe.rb, line 7 def initialize(name = nil, url = nil) @name = name @url = url @ingredients = [] @directions = [] end
today()
click to toggle source
# File lib/daily_recipes/recipe.rb, line 24 def self.today self.create @@recipes.sample end
Public Instance Methods
get_recipe()
click to toggle source
# File lib/daily_recipes/recipe.rb, line 29 def get_recipe doc2 = Nokogiri::HTML(open(self.url)) doc2.css("div.tasty-recipes-ingredients ul li").each {|item| @ingredients << item.text} doc2.css("div.tasty-recipes-instructions ol li").each {|step| @directions << step.text} end