Class: Lifelike::LifelikeCellularAutomaton::WorldSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/lifelike/lifelike_cellular_automaton/world_serializer.rb

Instance Method Summary collapse

Constructor Details

#initialize(cell_serializer) ⇒ WorldSerializer

Returns a new instance of WorldSerializer.



4
5
6
# File 'lib/lifelike/lifelike_cellular_automaton/world_serializer.rb', line 4

def initialize(cell_serializer)
  @cell_serializer = cell_serializer
end

Instance Method Details

#dump(world) ⇒ Object



12
13
14
# File 'lib/lifelike/lifelike_cellular_automaton/world_serializer.rb', line 12

def dump(world)
  cell_grid_to_string(world.cell_grid)
end

#load(string) ⇒ Object



8
9
10
# File 'lib/lifelike/lifelike_cellular_automaton/world_serializer.rb', line 8

def load(string)
  World.new(string_to_cell_grid(string))
end