#---
# Excerpted from "The ThoughtWorks Anthology",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material, 
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose. 
# Visit http://www.pragmaticprogrammer.com/titles/twa for more book information.
#---
require 'model'

# initial builder. Mix of method chaining and parameters.

class RulesBuilder1
  def initialize
    @configuration = Configuration.new
  end

  def item srcSymbol
    @current_item = Item.new srcSymbol
    @configuration.add_item @current_item
    self
  end

  def load aStream
    instance_eval aStream.join("\n")
    return @configuration
  end

  def uses arg
    @current_item.add_usage @current_resource
    self
  end    

  def acid
    @current_resource = Acid.new
    self
  end

  def type acidType
    @current_resource.type = acidType
    self
  end
  def grade aNumber
    @current_resource.grade = aNumber
    self
  end

  def electricity powerNumber
    @current_resource = Electricity.new(powerNumber)
    self
  end
  
  def provides arg
    @current_item.add_provision(@current_resource)
    self
  end

  def depends_on arg
    @current_item.add_dependency(@configuration[arg])
  end
end

