Class: Zif::Services::ServiceGroup

Inherits:
Object
  • Object
show all
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.

Examples:

Invoke a method on the TickTraceService via the ServiceGroup instance on a Game

$game.services[:tracer].mark("Hello World")

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeServiceGroup

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

#servicesArray<Zif::Services> (readonly)

Returns The registered services.

Returns:



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.

Parameters:

  • name (Symbol)

    The name of a service

Returns:



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.

Parameters:



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.

Parameters:

  • name (Symbol)

    The name of a service

Returns:



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.

Parameters:



41
42
43
# File 'lib/zif/services/service_group.rb', line 41

def register(name, new_service)
  @services[name] = new_service
end