Class: Blurrily::MapGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/blurrily/map_group.rb

Instance Method Summary collapse

Constructor Details

#initialize(directory = nil) ⇒ MapGroup

Returns a new instance of MapGroup.


7
8
9
10
# File 'lib/blurrily/map_group.rb', line 7

def initialize(directory = nil)
  @directory = Pathname.new(directory || Dir.pwd)
  @maps = {}
end

Instance Method Details

#clear(name) ⇒ Object


23
24
25
# File 'lib/blurrily/map_group.rb', line 23

def clear(name)
  @maps[name] = Map.new
end

#map(name) ⇒ Object


12
13
14
# File 'lib/blurrily/map_group.rb', line 12

def map(name)
  @maps[name] ||= load_map(name) || Map.new
end

#saveObject


16
17
18
19
20
21
# File 'lib/blurrily/map_group.rb', line 16

def save
  @directory.mkpath
  @maps.each do |name, map|
    map.save(path_for(name).to_s)
  end
end