Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multi-step instructions and single-block ingredients #15

Open
skalee opened this issue Feb 25, 2016 · 0 comments
Open

Support multi-step instructions and single-block ingredients #15

skalee opened this issue Feb 25, 2016 · 0 comments

Comments

@skalee
Copy link

skalee commented Feb 25, 2016

According to http://schema.org/Recipe definition, recipe instructions may be either a block of text or a list. Same thing when it comes to ingredients. However Hangry always returns an array of strings for ingredients and string for instructions, therefore it loses important piece of information.

Fortunately when it comes to instructions, the loss is easy to revert. Instructions are typically joined with "\n" and I can split this string to get original list. It doesn't seem right though, it's actually parsing the output of parser, I guess Hangry should do that.

When it comes to ingredients, it's much worse. For recipes which describe the ingredients as a block of text, this field will be usually blank. And modifying Hangry so that it returns one-item-long array doesn't seem right too.

In my opinion, Hangry's #instructions should return an array of strings if given recipe differentiate steps, and string otherwise. Similarly #ingredients should not be guaranteed to be an array. In Ruby it's not uncommon that class of some method's return value depends on situation.

I can implement it tomorrow, but it would be a breaking change, therefore I wanted to consult the interfaces before I start.

Alternatively, another methods #instructions_list, #ingredients_list, #instructions_text and #ingredients_text could be implemented. The "list" methods would return nil when only plain text is available. This approach does not introduce a breaking change, on the other hand provide 6 methods to access these two fields can be pretty confusing I think. Perhaps #instructions and #ingredients should be deprecated then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant