Class: FoodIngredientParser::Strict::Parser
- Inherits:
-
Object
- Object
- FoodIngredientParser::Strict::Parser
- Defined in:
- lib/food_ingredient_parser/strict/parser.rb
Instance Attribute Summary collapse
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Instance Method Summary collapse
-
#initialize ⇒ FoodIngredientParser::Parser
constructor
Create a new food ingredient parser.
-
#parse(s, clean: true, **options) ⇒ FoodIngredientParser::Grammar::RootNode
Parse food ingredient list text into a structured representation.
Constructor Details
#initialize ⇒ FoodIngredientParser::Parser
Create a new food ingredient parser
14 15 16 |
# File 'lib/food_ingredient_parser/strict/parser.rb', line 14 def initialize @parser = Grammar::RootParser.new end |
Instance Attribute Details
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
10 11 12 |
# File 'lib/food_ingredient_parser/strict/parser.rb', line 10 def parser @parser end |
Instance Method Details
#parse(s, clean: true, **options) ⇒ FoodIngredientParser::Grammar::RootNode
Note:
Unrecognized options are passed to Treetop, but this is not guarenteed to remain so forever.
Parse food ingredient list text into a structured representation.
23 24 25 26 |
# File 'lib/food_ingredient_parser/strict/parser.rb', line 23 def parse(s, clean: true, **) s = FoodIngredientParser::Cleaner.clean(s) if clean @parser.parse(s, **) end |