class TopasEngine
Public Class Methods
create(system, topasdir)
click to toggle source
# 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
new(topasdir)
click to toggle source
# 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
Public Instance Methods
tc(dir, input)
click to toggle source
# 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
Private Instance Methods
command(filename)
click to toggle source
# File lib/topas-tools/TopasEngine.rb, line 35 def command filename filepath = File.expand_path filename dirpath = File.dirname filepath outfile = File.join dirpath, filename.sub(/\..{2,3}$/ , '.out') "cp #{filepath} #{outfile}" end