class Tychus::Parsers::Base
Attributes
doc[R]
recipe[R]
recipe_doc[R]
uri[R]
Public Class Methods
new(uri)
click to toggle source
# File lib/tychus/parsers/base.rb, line 31 def initialize(uri) @uri = uri @recipe = Recipe.new @doc = Nokogiri::HTML(open(uri)) @recipe_doc = root_doc ? @doc.css(root_doc) : @doc end
recipe_attributes()
click to toggle source
# File lib/tychus/parsers/base.rb, line 9 def self.recipe_attributes # TODO: clear up these attributes. Are they used? Real example to # verify? # recipeType # photo # published # summary # review - see schema.org/Review %i[ name author description prep_time cook_time total_time recipe_yield ingredients recipe_instructions image ] end
Public Instance Methods
Value(obj)
click to toggle source
# File lib/tychus/parsers/base.rb, line 58 def Value(obj) case obj when NullObject then nil else obj end end
clean_instructions(obj)
click to toggle source
# File lib/tychus/parsers/base.rb, line 38 def clean_instructions(obj) obj end
parse()
click to toggle source
# File lib/tychus/parsers/base.rb, line 42 def parse recipe_attributes.each do |attr| property_value = __send__("parse_#{attr}") recipe.__send__("#{attr}=", Value(property_value)) end recipe end
recipe_attributes()
click to toggle source
# File lib/tychus/parsers/base.rb, line 50 def recipe_attributes self.class.recipe_attributes end
root_doc()
click to toggle source
# File lib/tychus/parsers/base.rb, line 54 def root_doc nil end