Class: Zif::Services::ServiceGroup
- Inherits:
-
Object
- Object
- Zif::Services::ServiceGroup
- Defined in:
- lib/zif/services/service_group.rb
Overview
Register a group of Zif::Services.
Game automatically saves an instance of this class at the $services global variable, and registers the typical services (InputService, ActionService…) on it for you. It’s also accessible through the Game instance via Game#services.
Instance Attribute Summary collapse
-
#services ⇒ Array<Zif::Services>
readonly
The registered services.
Instance Method Summary collapse
-
#[](name) ⇒ Zif::Services
A Zif::Services previously registered with
name
. -
#[]=(name, new_service) ⇒ Object
Register a service by name.
-
#initialize ⇒ ServiceGroup
constructor
A new instance of ServiceGroup.
-
#named(name) ⇒ Zif::Services
A Zif::Services previously registered with
name
. -
#register(name, new_service) ⇒ Object
Register a service by name.
Constructor Details
#initialize ⇒ ServiceGroup
Returns a new instance of ServiceGroup.
15 16 17 |
# File 'lib/zif/services/service_group.rb', line 15 def initialize @services = {} end |
Instance Attribute Details
#services ⇒ Array<Zif::Services> (readonly)
Returns The registered services.
13 14 15 |
# File 'lib/zif/services/service_group.rb', line 13 def services @services end |
Instance Method Details
#[](name) ⇒ Zif::Services
Returns A Zif::Services previously registered with name
.
21 22 23 |
# File 'lib/zif/services/service_group.rb', line 21 def [](name) @services[name] end |
#[]=(name, new_service) ⇒ Object
Register a service by name.
34 35 36 |
# File 'lib/zif/services/service_group.rb', line 34 def []=(name, new_service) @services[name] = new_service end |
#named(name) ⇒ Zif::Services
Returns A Zif::Services previously registered with name
.
27 28 29 |
# File 'lib/zif/services/service_group.rb', line 27 def named(name) @services[name] end |
#register(name, new_service) ⇒ Object
Register a service by name.
41 42 43 |
# File 'lib/zif/services/service_group.rb', line 41 def register(name, new_service) @services[name] = new_service end |