Usage
result = Ingreedy.parse('1 lb. potatoes')
print result.amount
print result.unit
print result.ingredient
I18n and custom dictionaries
Ingreedy.dictionaries[:fr] = {
units: { dash: ['pincée'] },
numbers: { 'une' => 1 },
prepositions: ['de']
}
Ingreedy.locale = :fr
result = Ingreedy.parse('une pincée de sucre')
print result.amount
print result.unit
print result.ingredient
Handling amounts
By default, Ingreedy will convert all amounts to a rational number:
result = Ingreedy.parse("1 1/2 cups flour")
print result.amount
However, setting Ingreedy.preverse_amounts = true
, will allow amounts
to be detected and returned as originally input:
Ingreedy.preserve_amounts = true
result = Ingreedy.parse("1 1/2 cups flour")
print result.amount
Live demo
Pieces of Flair
Development
Run the tests:
rspec spec