class Openvibe::Launcher
Public Class Methods
new(designer_path, scenario_ , mode_ = "--open", options_ = [""])
click to toggle source
# File lib/openvibe-launcher.rb, line 20 def initialize(designer_path, scenario_ , mode_ = "--open", options_ = [""]) # check if designer script exists if File.exists?(designer_path) @path = designer_path else Error.critical("Designer script #{designer_path} not found") end @options = Array.new @prefix = nil # add scenario, mode and options self.scenario= scenario_ self.mode= mode_ self.options= options_ end
Public Instance Methods
mode=(mode)
click to toggle source
mode accessor
# File lib/openvibe-launcher.rb, line 82 def mode=(mode) allowedmode = ["--open","--play","--play-fast"] if allowedmode.include?(mode) @mode = mode else Error.critical("mode #{mode} not allowed ! Choose one of the following : #{allowedmode.join(' , ')}.") end end
options=(opt)
click to toggle source
options accessor
# File lib/openvibe-launcher.rb, line 92 def options=(opt) allowedopt = ["--no-gui","--no-session-management",""] opt.each do |o| if allowedopt.include?(o) @options.push(o) else Error.critical("Option #{o} not allowed ! Choose one of the following : #{allowedopt.join(' , ')}.") end end end
play()
click to toggle source
# File lib/openvibe-launcher.rb, line 50 def play @mode = "--play" self.start end
playfast()
click to toggle source
# File lib/openvibe-launcher.rb, line 55 def playfast @mode = "--play-fast" self.start end
scenario=(sc)
click to toggle source
scenario accessor
# File lib/openvibe-launcher.rb, line 73 def scenario=(sc) if File.exists?(sc) @scenario = sc else Error.critical("Scenario File #{sc} not found") end end
setEnv(hash)
click to toggle source
# File lib/openvibe-launcher.rb, line 60 def setEnv(hash) @env = hash end
setOutput(str)
click to toggle source
# File lib/openvibe-launcher.rb, line 64 def setOutput(str) @out = str end
setPrefix(str)
click to toggle source
# File lib/openvibe-launcher.rb, line 68 def setPrefix(str) @prefix = str end
start()
click to toggle source
# File lib/openvibe-launcher.rb, line 38 def start self.start! Process.waitpid(@pid) end
start!()
click to toggle source
# File lib/openvibe-launcher.rb, line 43 def start! dir = File.dirname(@path) command = "#{@prefix} #{@path} #{@mode} #{@scenario} #{@options.join(' ')}" @pid = spawn(@env || {},command,:out=> @out || STDOUT,:chdir => dir ) Process.detach(@pid) end