Module: Omega::Client::TrackEntity

Included in:
Ship, SolarSystem, Station
Defined in:
lib/omega/client/mixins/track_entity.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.clear_entitiesObject

Clear all entities


43
44
45
# File 'lib/omega/client/mixins/track_entity.rb', line 43

def self.clear_entities
  @entities = []
end

.entitiesObject

Return all entities in all classes w/ TrackEntity.entities


38
39
40
# File 'lib/omega/client/mixins/track_entity.rb', line 38

def self.entities
  @entities
end

.included(base) ⇒ Object

The class methods below will be defined on the class including this module

See Also:


13
14
15
16
17
18
19
20
21
22
23
# File 'lib/omega/client/mixins/track_entity.rb', line 13

def self.included(base)
  @entities ||= []

  base.extend(ClassMethods)

  # On initialization register entities w/ registry,
  # deleting old entity if it exists
  base.entity_init { |e|
    TrackEntity.track_entity e
  }
end

.track_entity(e) ⇒ Object

Track specified entity


31
32
33
34
35
# File 'lib/omega/client/mixins/track_entity.rb', line 31

def self.track_entity(e)
  o = @entities.find { |re| re.id == e.id }
  @entities.delete(o) unless o.nil?
  @entities << e
end

Instance Method Details

#entitiesObject

Instance wrapper around class.entities


26
27
28
# File 'lib/omega/client/mixins/track_entity.rb', line 26

def entities
  self.class.entities
end