class IngredientParser::Ingredient

Attributes

amount[R]
name[R]

Public Class Methods

new(name, amount) click to toggle source
# File lib/ingredient_parser/ingredient.rb, line 4
def initialize(name, amount)
  @name = normalize(name)
  @amount = normalize(amount)
end

Private Instance Methods

normalize(value) click to toggle source
# File lib/ingredient_parser/ingredient.rb, line 11
def normalize(value)
  case value
  when NilClass
    nil
  when Parslet::Slice
    value.str.strip
  when String
    if value.empty?
      nil
    else
      value.strip
    end
  end
end