Class: Tychus::Parsers::KraftRecipesParser
Instance Attribute Summary
Attributes inherited from Base
#doc, #recipe, #recipe_doc, #uri
Class Method Summary
collapse
Instance Method Summary
collapse
#initialize, #itemprop_node_for, review_doc, root_doc, #strip_review_microformat, #strip_video_object_microformat, video_object_doc
Methods inherited from Base
#Value, #clean_instructions, #initialize, #parse, #parse_author, #parse_cook_time, #parse_duration, #parse_image, #parse_prep_time, #parse_recipe_yield, #parse_total_time, recipe_attributes, #recipe_attributes
Class Method Details
.uri_host ⇒ Object
6
7
8
|
# File 'lib/tychus/parsers/kraft_recipes_parser.rb', line 6
def self.uri_host
"kraftrecipes.com"
end
|
Instance Method Details
#parse_description ⇒ Object
10
11
12
13
14
|
# File 'lib/tychus/parsers/kraft_recipes_parser.rb', line 10
def parse_description
doc.css('meta[name="description"]').first.attr('content')
end
|
#parse_ingredients ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/tychus/parsers/kraft_recipes_parser.rb', line 34
def parse_ingredients
recipe_doc
.css('[itemprop="ingredients"]')
.map do|ingredient_node|
ingredient_node
.element_children
.map do |node| node.content
.lstrip
.rstrip
.squeeze(" ")
.gsub(/(\r|\n|\t)/,'')
end.join(" ")
end.reject(&:blank?)
end
|
#parse_name ⇒ Object
16
17
18
19
20
|
# File 'lib/tychus/parsers/kraft_recipes_parser.rb', line 16
def parse_name
result = super
result.gsub(/(\r|\n|\t)/,'')
end
|
#parse_recipe_instructions ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/tychus/parsers/kraft_recipes_parser.rb', line 22
def parse_recipe_instructions
itemprop_node_for(:recipeInstructions)
.element_children
.map do|x|
x.content
.squeeze(" ")
.rstrip
.split("\r\n\t")
.map{|x|x.gsub(/\t/,'')}
end.flatten.reject(&:blank?)
end
|