Module: UniverseCompiler::Universe::Multiverse

Included in:
Base
Defined in:
lib/universe_compiler/universe/multiverse.rb

Constant Summary collapse

DEFAULT_UNIVERSE_NAME =
'Unnamed Universe'.freeze

Instance Method Summary collapse

Instance Method Details

#get_unique_name(seed = DEFAULT_UNIVERSE_NAME) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/universe_compiler/universe/multiverse.rb', line 19

def get_unique_name(seed = DEFAULT_UNIVERSE_NAME)
  if universes[seed]
    format_name seed, SecureRandom.uuid
  else
    seed
  end
end

#register(universe) ⇒ Object



14
15
16
17
# File 'lib/universe_compiler/universe/multiverse.rb', line 14

def register(universe)
  raise UniverseCompiler::Error, "Universe '#{universe.name}' already exists in this continuum !" if universes.keys.include? universe.name
  universes[universe.name] = universe
end

#universesObject



10
11
12
# File 'lib/universe_compiler/universe/multiverse.rb', line 10

def universes
  @universes ||= {}
end