Sha256: ce1671e6becf1f35087149a68731411b4f4de13997846f9f0e2d26ec2375f61d

Contents?: true

Size: 798 Bytes

Versions: 6

Compression:

Stored size: 798 Bytes

Contents

module Hangry
  class DataVocabularyRecipeParser < SchemaOrgRecipeParser

    def self.root_selector
      '[itemtype="http://data-vocabulary.org/Recipe"]'
    end

    def self.nutrition_selector
      '[itemtype="http://data-vocabulary.org/NutritionInformation"]'
    end

    def self.ingredient_itemprop
      :ingredient
    end

    private

    def parse_description
      clean_string node_with_itemprop(:summary).content
    end

    def parse_instructions
      clean_string node_with_itemprop(:instructions).content, preserve_newlines: true
    end

    def parse_published_date
      content = node_with_itemprop(:published).content
      content.blank? ? nil : Date.parse(content)
    end

    def parse_yield
      clean_string node_with_itemprop(:yield).content
    end

  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hangry-0.0.11 lib/hangry/data_vocabulary_recipe_parser.rb
hangry-0.0.10 lib/hangry/data_vocabulary_recipe_parser.rb
hangry-0.0.9 lib/hangry/data_vocabulary_recipe_parser.rb
hangry-0.0.8 lib/hangry/data_vocabulary_recipe_parser.rb
hangry-0.0.7 lib/hangry/data_vocabulary_recipe_parser.rb
hangry-0.0.6 lib/hangry/data_vocabulary_recipe_parser.rb