#---
# 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 RulesBuilder19
  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 arg
    self
  end    

  def acid args 
    result = Acid.new
    result.grade = args[:grade]
    result.type = args[:type]
    return result
  end

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

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

