Sha256: 43ff896018330d72b073c38f79330eb53f8feb034d99fa85cf4690b3cade9ac9

Contents?: true

Size: 863 Bytes

Versions: 2

Compression:

Stored size: 863 Bytes

Contents

module Epilicious
  class Parser

    def parse_recipes_page(page)
      page.css('#artInner .recipe_result_right a').map {|link| link ['href'] }
    end

    def parse_recipe_page(page)
      recipe = {}
      recipe[:name]        = name(page) 
      recipe[:servings]    = servings(page) 
      recipe[:ingredients] = ingredients(page) 
      recipe[:instructions] = instructions(page) 
      recipe
    end

    private
    
    def name(page)
      page.css("div#headline h1").text 
    end

    def servings(page)
      page.css("div#recipe_summary p span").first.text 
    end

    def ingredients(page)
      ingredients_list = page.css("ul.ingredientsList li")
      ingredients_list.map {|li| li.text}
    end

    def instructions(page)
      preparation = page.css("div#preparation.instructions p")
      preparation.map {|i| i.text}
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
epilicious-0.1.1 lib/epilicious/parser.rb
epilicious-0.1.0 lib/epilicious/parser.rb