Sha256: 388909ccac528694d7c165f8e265085613a485b928f293529f6793014c6b5d5a

Contents?: true

Size: 449 Bytes

Versions: 1

Compression:

Stored size: 449 Bytes

Contents

require 'parslet'

require "ingredient_parser/version"
require 'ingredient_parser/parser'
require 'ingredient_parser/ingredient'

module Parslet
  class ParseFailed < StandardError
    alias_method :parse_failure_cause, :cause

    def cause
      nil
    end
  end
end

module IngredientParser
  extend self

  @parser = Parser.new

  def self.parse(str)
    parsed = @parser.parse(str)
    Ingredient.new(parsed[:name], parsed[:amount])
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ingredient_parser-0.1.0 lib/ingredient_parser.rb