class Epilicious::Fetcher

Attributes

recipes[R]

Public Class Methods

new() click to toggle source
# File lib/epilicious/fetcher.rb, line 11
def initialize
  @recipes ||= []
  @base_url = "http://www.epicurious.com"
end

Public Instance Methods

fetch_recipe(url) click to toggle source
# File lib/epilicious/fetcher.rb, line 25
def fetch_recipe(url)
  recipe_page = fetch_page(url)
  recipe = parser.parse_recipe_page(recipe_page)
  Recipe.new(recipe)
end
fetch_recipes(index_url) click to toggle source
# File lib/epilicious/fetcher.rb, line 16
def fetch_recipes(index_url)
  recipes_page = fetch_page(index_url)
  recipes_urls = parser.parse_recipes_page(recipes_page)
  recipes = recipes_urls.map do |url|
    fetch_recipe(url)
  end
  recipes
end

Private Instance Methods

fetch_page(url) click to toggle source
# File lib/epilicious/fetcher.rb, line 33
def fetch_page(url)
  Nokogiri::HTML(open(@base_url + url))
end
parser() click to toggle source
# File lib/epilicious/fetcher.rb, line 37
def parser
  @parser ||= Parser.new
end