Sha256: 58ecd74345fa420cbe4901fa3bfe9cb53ae3c6e54ce58bffbec390612fbbfb8d
Contents?: true
Size: 798 Bytes
Versions: 9
Compression:
Stored size: 798 Bytes
Contents
require File.expand_path( "../project", __FILE__) # Responsible for creating projects when needed. # Creates them from XML received. class ProjectFactory attr_reader :project, :projects def initialize @project = Project.new @projects = [] end def create_projects_from_xml(xml) xml.split("\n").each do |line| /<name[^>]*>(.*)<\/name>/ =~ line name = $1 project.name = name.capitalize if name /<id[^>]*>(.*)<\/id>/ =~ line id = $1 project.id = id if id /<api-key[^>]*>(.*)<\/api-key>/ =~ line api_key = $1 project.api_key = api_key if api_key check_project end end def check_project if @project.valid? projects << @project @project = Project.new end end end
Version data entries
9 entries across 9 versions & 2 rubygems