class Epilicious::Parser

Public Instance Methods

parse_recipe_page(page) click to toggle source
# File lib/epilicious/parser.rb, line 8
def parse_recipe_page(page)
  recipe = {}
  recipe[:name]        = name(page) 
  recipe[:servings]    = servings(page) 
  recipe[:ingredients] = ingredients(page) 
  recipe[:instructions] = instructions(page) 
  recipe
end
parse_recipes_page(page) click to toggle source
# File lib/epilicious/parser.rb, line 4
def parse_recipes_page(page)
  page.css('.recipe_result_right a').map {|link| link ['href'] }
end

Private Instance Methods

ingredients(page) click to toggle source
# File lib/epilicious/parser.rb, line 27
def ingredients(page)
  ingredients_list = page.css("ul.ingredientsList li")
  ingredients_list.map {|li| li.text}
end
instructions(page) click to toggle source
# File lib/epilicious/parser.rb, line 32
def instructions(page)
  preparation = page.css("div#preparation.instructions p")
  preparation.map {|i| i.text.strip.gsub("\n", ' ').squeeze(' ')}
end
name(page) click to toggle source
# File lib/epilicious/parser.rb, line 19
def name(page)
  page.css("div#headline h1").text 
end
servings(page) click to toggle source
# File lib/epilicious/parser.rb, line 23
def servings(page)
  page.css("div#recipe_summary p span").first.text 
end