Class: Ruber::World::ProjectFactory
- Defined in:
- lib/ruber/world/project_factory.rb
Overview
Defined Under Namespace
Classes: MismatchingNameError
Instance Method Summary collapse
-
#initialize(parent = nil) ⇒ ProjectFactory
constructor
A new instance of ProjectFactory.
-
#project(file, name = nil) ⇒ Project
Retrieves the project associated with a given project file.
Constructor Details
#initialize(parent = nil) ⇒ ProjectFactory
Returns a new instance of ProjectFactory.
81 82 83 84 |
# File 'lib/ruber/world/project_factory.rb', line 81 def initialize parent = nil super @projects = {} end |
Instance Method Details
#project(file, name = nil) ⇒ Project
Retrieves the project associated with a given project file
If a project associated with the project file file already exists, that project is returned. Otherwise, a new project is created. In this case, the #project_created signal is emitted
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/ruber/world/project_factory.rb', line 98 def project file, name = nil prj = @projects[file] if prj if name and prj.project_name != name raise MismatchingNameError.new file, name, prj.project_name end prj else prj = Project.new file, name connect prj, SIGNAL('closing(QObject*)'), self, SLOT('project_closing(QObject*)') @projects[prj.project_file] = prj emit project_created prj prj end end |