Class: Hangry::ParserClassSelecter

Inherits:
Object
  • Object
show all
Defined in:
lib/hangry/parser_class_selecter.rb

Instance Method Summary collapse

Constructor Details

#initialize(html) ⇒ ParserClassSelecter

Returns a new instance of ParserClassSelecter.



11
12
13
# File 'lib/hangry/parser_class_selecter.rb', line 11

def initialize(html)
  @html = html
end

Instance Method Details

#parser_classObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/hangry/parser_class_selecter.rb', line 15

def parser_class
  # Prefer the more specific parsers
  parser_classes = [
    Parsers::NonStandard::AllRecipesParser,
    Parsers::NonStandard::EatingWellParser
  ]
  parser_classes += [SchemaOrgRecipeParser, HRecipeParser, DataVocabularyRecipeParser]
  parser_classes << DefaultRecipeParser
  parser_classes.detect { |p| p.can_parse?(@html) }
end