class Action

Public Class Methods

cut(amount:, ingredient:) click to toggle source
# File lib/actions.rb, line 3
def cut(amount:, ingredient:)
  raise ArgumentError, "#{ingredient.class.name} is not cuttable" unless ingredient.cuttable?
  step = "🔪 #{ingredient.title}"
  # loop do
  #   step += '🔪'
  #   ingredient.condition += 1
  #   break if finish_condition?(ingredient.condition, amount)
  # end
  puts step
end
mix(kitchenware:, ingredients: []) click to toggle source
# File lib/actions.rb, line 14
def mix(kitchenware:, ingredients: [])
  raise ArgumentError, "#{kitchenware.class.name} can't mix" unless kitchenware.actions.include?(:mix)
  step = "🌀 #{kitchenware.title} #{ingredients.map(&:title).join}"
  puts step
end
pickle(kitchenware:, ingredients: []) click to toggle source
# File lib/actions.rb, line 20
def pickle(kitchenware:, ingredients: [])
  raise ArgumentError, "#{kitchenware.class.name} can't pickle" unless kitchenware.actions.include?(:pickle)
  step = "(pickle) #{kitchenware.title} #{ingredients.map(&:title).join}"
  puts step
end
toast(kitchenware: nil, ingredients: []) click to toggle source
# File lib/actions.rb, line 26
def toast(kitchenware: nil, ingredients: [])
  raise ArgumentError, "#{kitchenware.class.name} can't toast" if kitchenware && !kitchenware.actions.include?(:toast)
  step = "🍳🔥 #{ingredients.map(&:title).join}"
  puts step
end

Private Class Methods

finish_condition?(condition, arg) click to toggle source
# File lib/actions.rb, line 34
def finish_condition?(condition, arg)
  condition >= arg
end