Class: Ruber::World::ProjectFactory
- Inherits:
-
Qt::Object
- Object
- Qt::Object
- Ruber::World::ProjectFactory
- Defined in:
- lib/ruber/world/project_factory.rb
Overview
Defined Under Namespace
Classes: MismatchingNameError
Instance Method Summary (collapse)
-
- (ProjectFactory) initialize(parent = nil)
constructor
A new instance of ProjectFactory.
-
- (Project) project(file, name = nil)
Retrieves the project associated with a given project file.
-
- (nil) project_closing(prj)
slot
private
Method called whenever a project is closed.
Signal Summary
-
- project_created(QObject* prj)
Signal emitted when a new project object is created.
Constructor Details
- (ProjectFactory) initialize(parent = nil)
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) project(file, name = nil)
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 |
- (nil) project_closing(prj) (private)
Method called whenever a project is closed
It ensures that the list of open projects is up to date
122 123 124 125 |
# File 'lib/ruber/world/project_factory.rb', line 122 def project_closing prj @projects.delete prj.project_file nil end |
Slot Signature:
project_closing(QObject*)
Signal Details
- project_created(QObject* prj)
Signal emitted when a new project object is created
The signal is emitted when a new project object is created, either from an existing project file or for a new project file.