class Tychus::Parsers::KraftRecipesParser

Public Class Methods

uri_host() click to toggle source
# File lib/tychus/parsers/kraft_recipes_parser.rb, line 6
def self.uri_host
  "kraftrecipes.com"
end

Public Instance Methods

parse_description() click to toggle source
# File lib/tychus/parsers/kraft_recipes_parser.rb, line 10
def parse_description
  # description can be found in .recipeDesc or meta tag in header
  # TODO: pull out meta tag parsing into own methods/class?
  doc.css('meta[name="description"]').first.attr('content')
end
parse_ingredients() click to toggle source
# File lib/tychus/parsers/kraft_recipes_parser.rb, line 16
def parse_ingredients
  # "1 lb.\r\n\t\t\t\t\t\t\t\t boneless skinless chicken breasts, cut into 1-1/2-inch pieces", "2 cups\r\n\t\t\t\t\t\t\t\t fresh pineapple chunks (1-1/2 inch)", "1 \r\n\t\t\t\t\t\t\t\t each red and green pepper, cut into 1-1/2-inch pieces", "1/2 cup\r\n\t\t\t\t\t\t\t\t KRAFT Original Barbecue Sauce", "3 Tbsp.\r\n\t\t\t\t\t\t\t\t frozen orange juice concentrate, thawed"
  recipe_doc
    .css('[itemprop="ingredients"]')
    .map do|ingredient_node|
      ingredient_node
        .element_children
        .map do |node| node.content
          .lstrip
          .rstrip
          .squeeze(" ")
          .gsub(/(\r|\n|\t)/,'')
        end.join(" ")
    end.reject(&:blank?)
end
parse_name() click to toggle source
Calls superclass method
# File lib/tychus/parsers/kraft_recipes_parser.rb, line 33
def parse_name
  # "\r\n\tSweet BBQ Chicken Kabobs\r\n\t"
  result = super
  result.gsub(/(\r|\n|\t)/,'')
end
parse_recipe_instructions() click to toggle source
# File lib/tychus/parsers/kraft_recipes_parser.rb, line 39
def parse_recipe_instructions
  itemprop_node_for(:recipeInstructions)
    .element_children
    .map do|x|
      x.content
        .squeeze(" ")
        .rstrip
        .split("\r\n\t")
        .map{|x|x.gsub(/\t/,'')}
    end.flatten.reject(&:blank?)
end