Module: RecipeScrapers::Scraper::ParsedFields::ClassMethods

Defined in:
lib/recipe_scrapers/scraper/parsed_fields.rb

Overview

The class methods a scraper class gets from RecipeScrapers::Scraper::ParsedFields.

Instance Method Summary collapse

Instance Method Details

#own_parsers ⇒ Hash{Symbol => Array<#call>}

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the parsers this class sets with #parser.



30
31
32
# File 'lib/recipe_scrapers/scraper/parsed_fields.rb', line 30

def own_parsers
  @own_parsers ||= {}
end

#parser(field, *parsers) ⇒ Object

Sets the parsers of a field for every page of this scraper class. It wins over the site declaration and the configuration.

Raises:

  • (ArgumentError) —

    for a field that takes no parser



23
24
25
# File 'lib/recipe_scrapers/scraper/parsed_fields.rb', line 23

def parser(field, *parsers)
  own_parsers[Parsers::Chain.field!(field)] = parsers
end