require "take/project/requirement/base" require "take/project/requirement/library" require "take/project/requirement/header" require "take/project/requirement/program" module Take class Project module Requirement def self.convert(hash, project, &blk) if hash.size > 1 raise ArgumentError, "Cannot use a block for a " \ "multi-requirement!" if block_given? end requirements = [] hash.each do |key, value| requirement_class = lookup(key) requirement = requirement_class.new(key, value, project, &blk) requirements << requirement end requirements end def self.lookup(name) case name when :header Header when :library Library when :program Program when Class name else raise ArgumentError, "Unknown requirement #{name.inspect}!" end end end end end