Class: Rook::Cooking

Inherits:
Object
  • Object
show all
Defined in:
lib/rook/kitchen.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(goal_product) ⇒ Cooking

Returns a new instance of Cooking.



670
671
672
673
674
# File 'lib/rook/kitchen.rb', line 670

def initialize(goal_product)
  @goal_product = goal_product
  @cooked = {}
  @now_cooking = {}
end

Instance Attribute Details

#cookedObject (readonly)

Returns the value of attribute cooked.



675
676
677
# File 'lib/rook/kitchen.rb', line 675

def cooked
  @cooked
end

#goal_productObject (readonly)

Returns the value of attribute goal_product.



675
676
677
# File 'lib/rook/kitchen.rb', line 675

def goal_product
  @goal_product
end

Instance Method Details

#cooked?(product) ⇒ Boolean

Returns:

  • (Boolean)


678
679
680
# File 'lib/rook/kitchen.rb', line 678

def cooked?(product)
  return @cooked.key?(product)
end

#finish(recipe) ⇒ Object



695
696
697
698
699
# File 'lib/rook/kitchen.rb', line 695

def finish(recipe)
  recipe.all_products.each do |prod|
    @cooked[prod] = @now_cooking.delete(prod)
  end
end

#now_cooking?(product) ⇒ Boolean

Returns:

  • (Boolean)


683
684
685
# File 'lib/rook/kitchen.rb', line 683

def now_cooking?(product)
  return @now_cooking.key?(product)
end

#start(recipe) ⇒ Object



688
689
690
691
692
# File 'lib/rook/kitchen.rb', line 688

def start(recipe)
  recipe.all_products.each do |prod|
    @now_cooking[prod] = recipe
  end
end