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.



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

def initialize(html)
  @html = html
end

Instance Method Details

#parser_classObject



14
15
16
17
18
19
20
# File 'lib/hangry/parser_class_selecter.rb', line 14

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