Class: TopasEngine
- Inherits:
-
Object
show all
- Defined in:
- lib/topas-tools/TopasEngine.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(topasdir) ⇒ TopasEngine
Returns a new instance of TopasEngine.
15
16
17
18
19
20
|
# File 'lib/topas-tools/TopasEngine.rb', line 15
def initialize topasdir
@enc = 'UTF-8'
Dir.exists?(topasdir) || raise("Non-existing directory!")
Dir.entries(topasdir).any?{|f| f == 'tc.exe'} || raise("Where is my tc.exe?!")
@topasdir = topasdir
end
|
Class Method Details
.create(system, topasdir) ⇒ Object
2
3
4
5
6
7
8
9
10
11
12
13
|
# File 'lib/topas-tools/TopasEngine.rb', line 2
def self.create system, topasdir
case system
when :wine
WineTopasEngine.new topasdir
when :windows
WindowsTopasEngine.new topasdir
when :dummy
TopasEngine.new topasdir
else
raise "Bad system: #{system}"
end
end
|
Instance Method Details
#tc(dir, input) ⇒ Object
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/topas-tools/TopasEngine.rb', line 22
def tc dir, input
infile = "#{input.name}.inp"
Dir.chdir dir
File.open(infile, mode:'w'){|f| f.write input.text}
cmd = command infile
Dir.chdir @topasdir
system(cmd)
Dir.chdir dir
TopasInput.new IO.read("#{input.name}.out", :encoding => @enc)
end
|