Class: Hangry::Parsers::NonStandard::AllRecipesParser

Inherits:
SchemaOrgRecipeParser show all
Defined in:
lib/hangry/parsers/non_standard/all_recipes_parser.rb

Instance Attribute Summary

Attributes inherited from RecipeParser

#nokogiri_doc, #nutrition_ast, #recipe, #recipe_ast, #recipe_html

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SchemaOrgRecipeParser

ingredient_itemprop, nutrition_selector, root_selector

Methods inherited from RecipeParser

canonical_url_matches_domain?, #clean_nutrition, #initialize, #parse

Constructor Details

This class inherits a constructor from Hangry::RecipeParser

Class Method Details

.can_parse?(html) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/hangry/parsers/non_standard/all_recipes_parser.rb', line 6

def self.can_parse?(html)
  canonical_url_matches_domain?(html, 'allrecipes.com')
end

Instance Method Details

#parse_instructionsObject



10
11
12
13
# File 'lib/hangry/parsers/non_standard/all_recipes_parser.rb', line 10

def parse_instructions
  content = recipe_ast.css('.directions ol').first.content
  clean_string content, preserve_newlines: true
end