Class: FoodIngredientParser::Strict::Grammar::IngredientNode
- Inherits:
-
SyntaxNode
- Object
- Treetop::Runtime::SyntaxNode
- SyntaxNode
- FoodIngredientParser::Strict::Grammar::IngredientNode
- Defined in:
- lib/food_ingredient_parser/strict/nodes.rb
Overview
Ingredient
Direct Known Subclasses
Instance Method Summary collapse
Instance Method Details
#to_h ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/food_ingredient_parser/strict/nodes.rb', line 43 def to_h h = {} h.merge!(to_a_deep(ing, IngredientNode)&.first&.to_h || {}) if respond_to?(:ing) h.merge!(to_a_deep(amount, AmountNode)&.first&.to_h || {}) if respond_to?(:amount) h[:name] = name.text_value if respond_to?(:name) h[:name] = pre.text_value + h[:name] if respond_to?(:pre) h[:name] = h[:name] + post.text_value if respond_to?(:post) h[:marks] = [mark.text_value] if respond_to?(:mark) && mark.text_value != '' h end |