Class: FoodIngredientParser::Loose::Parser
- Inherits:
-
Object
- Object
- FoodIngredientParser::Loose::Parser
- Defined in:
- lib/food_ingredient_parser/loose/parser.rb
Instance Method Summary collapse
-
#initialize ⇒ FoodIngredientParser::StreamParser
constructor
Create a new food ingredient stream parser.
-
#parse(s, clean: true, normalize: true, **options) ⇒ FoodIngredientParser::Loose::Node
Parse food ingredient list text into a structured representation.
Constructor Details
#initialize ⇒ FoodIngredientParser::StreamParser
Create a new food ingredient stream parser
12 13 |
# File 'lib/food_ingredient_parser/loose/parser.rb', line 12 def initialize end |
Instance Method Details
#parse(s, clean: true, normalize: true, **options) ⇒ FoodIngredientParser::Loose::Node
Parse food ingredient list text into a structured representation.
20 21 22 23 24 25 26 27 |
# File 'lib/food_ingredient_parser/loose/parser.rb', line 20 def parse(s, clean: true, normalize: true, **) s = FoodIngredientParser::Cleaner.clean(s) if clean n = Scanner.new(s).scan n = Transform::Amount.transform!(n) if n n = Transform::SplitENumbers.transform!(n) if n n = Transform::HandleMissingName.transform!(n) if n && normalize n end |