Skip to content

A gem to parse plain text into "Ingredient" objects for use on recipe sites

Notifications You must be signed in to change notification settings

mikeyhogarth/tablecloth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NOTE: This is largely an experimental / personal project, and is highly unlikely to be useful to anyone but me!

This is an ingredients markdown for converting pure text into recipe objects for use on cooking websites. 

EXAMPLES
==========

Example usage;

tc = TableCloth::Recipe.new(:ingredients => "3 cups of sugar")

tc.ingredients.first.quantity
 => "3" 
tc.ingredients.first.unit
 => :cup 
tc.ingredients.first.item
 => "sugar" 

All of the following forms of ingredient text will also parse;

"2lbs Potatoes"
"2 lbs Potatoes"
"2 lb Potatoes"
"2lb Potatoes"
"1 tablespoon of sugar"
"1 bouquet garni"
"a cup of sugar"
"salt to taste"

You can also parse each ingredient back into a readable English string;

tb = TableCloth::Recipe.new(:ingredients => "1 cups sugar")
tb.ingredients.first.to_s
 => "1 cup of sugar" 

tb = TableCloth.new("2 cup sugar")
tb.ingredients.first.to_s
 => "2 cups of sugar" 

You can also generate html from the various parts of the object;

tc.ingredients.to_html
=> <ul><li>2 lbs Potatoes</li></ul>

About

A gem to parse plain text into "Ingredient" objects for use on recipe sites

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages