Class: CatEngine::Engine

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Defined in:
lib/cat_engine/engine.rb

Defined Under Namespace

Classes: EngineError

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.compileObject



10
11
12
13
# File 'lib/cat_engine/engine.rb', line 10

def self.compile
  gmcs = [`which gmcs`.chomp, `which mcs`.chomp].find { |path| path != "" }
  system "cd #{CatEngine.cat_engine_source_path} && #{gmcs} -debug -out:#{CatEngine.cat_engine_executable_path} *.cs"
end

Instance Method Details

#process(id, history) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/cat_engine/engine.rb', line 15

def process id, history
  command = %(cd #{CatEngine.cat_path} && mono --debug #{CatEngine.cat_engine_executable_path} "#{id}" #{history} 2>&1)
  output = `#{command}`.chomp
  if $?.success?
    Nokogiri::XML.parse(output, nil, "utf-8")
  else
    raise EngineError.new(output)
  end
end

#valid_history?(id, history) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
# File 'lib/cat_engine/engine.rb', line 26

def valid_history? id, history
  process id, history
  true
rescue EngineError => e
  false
end