class FoodIngredientParser::Strict::Parser

Attributes

parser[R]

@!attribute [r] parser

@return [Treetop::Runtime::CompiledParser] low-level parser object
@note This attribute is there for convenience, but may change in the future. Take care.

Public Class Methods

new() click to toggle source

Create a new food ingredient parser @return [FoodIngredientParser::Parser]

# File lib/food_ingredient_parser/strict/parser.rb, line 14
def initialize
  @parser = Grammar::RootParser.new
end

Public Instance Methods

parse(s, clean: true, **options) click to toggle source

Parse food ingredient list text into a structured representation.

@option clean [Boolean] pass false to disable correcting frequently occuring issues @return [FoodIngredientParser::Grammar::RootNode] structured representation of food ingredients @note Unrecognized options are passed to Treetop, but this is not guarenteed to remain so forever.

# File lib/food_ingredient_parser/strict/parser.rb, line 23
def parse(s, clean: true, **options)
  s = FoodIngredientParser::Cleaner.clean(s) if clean
  @parser.parse(s, **options)
end