Class: Astromapper::Builder::Sector
- Inherits:
-
Base
- Object
- Base
- Astromapper::Builder::Sector
show all
- Defined in:
- lib/astromapper/builder/sector.rb
Instance Attribute Summary
Attributes inherited from Base
#root_dir
Instance Method Summary
collapse
Methods inherited from Base
#config, constitute, #initialize, #names, #spawn_command, #toss
Instance Method Details
#constitute ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/astromapper/builder/sector.rb', line 4
def constitute
@volumes = []
40.times do |r|
32.times do |c|
next unless has_system?
v = Volume.new(c+1,r+1)
@volumes << v unless v.empty?
end
end
self
end
|
#has_system? ⇒ Boolean
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/astromapper/builder/sector.rb', line 15
def has_system?
case
when config['density'] == 'extra_galactic' then (1.d100 <= 1)
when config['density'] == 'rift' then (1.d100 <= 3)
when config['density'] == 'sparse' then (1.d100 <= 17)
when config['density'] == 'scattered' then (1.d100 <= 33)
when config['density'] == 'dense' then (1.d100 <= 66)
when config['density'] == 'cluster' then (1.d100 <= 83)
when config['density'] == 'core' then (1.d100 <= 91)
else (d100 <= 50) end
end
|
#to_file ⇒ Object
27
28
29
30
|
# File 'lib/astromapper/builder/sector.rb', line 27
def to_file
file = Astromapper.output_file('sector')
File.open(file,'w').write(@volumes.map{|v| v.to_ascii}.join("\n"))
end
|