Class: MatlabQueue

Inherits:
Object
  • Object
show all
Includes:
DefaultLogger
Defined in:
lib/matlab_helpers/matlab_queue.rb

Overview

Maintain and run matlab commands and paths.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DefaultLogger

#setup_logger

Constructor Details

#initializeMatlabQueue

Returns a new instance of MatlabQueue.



11
12
13
14
15
16
# File 'lib/matlab_helpers/matlab_queue.rb', line 11

def initialize
  @paths = []
  @commands = []
  @ml_command = "matlab -nosplash -nodesktop"
  setup_logger unless defined?($Log)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



28
29
30
# File 'lib/matlab_helpers/matlab_queue.rb', line 28

def method_missing(m, *args, &block)
  @commands.send(m, *args, &block)
end

Instance Attribute Details

#commandsObject

Returns the value of attribute commands.



8
9
10
# File 'lib/matlab_helpers/matlab_queue.rb', line 8

def commands
  @commands
end

#ml_commandObject

Returns the value of attribute ml_command.



8
9
10
# File 'lib/matlab_helpers/matlab_queue.rb', line 8

def ml_command
  @ml_command
end

#pathsObject

Returns the value of attribute paths.



8
9
10
# File 'lib/matlab_helpers/matlab_queue.rb', line 8

def paths
  @paths
end

#successObject (readonly)

Returns the value of attribute success.



9
10
11
# File 'lib/matlab_helpers/matlab_queue.rb', line 9

def success
  @success
end

Instance Method Details

#add_to_path(*args) ⇒ Object

Add paths that should be available for Matlab scripts.



33
34
35
# File 'lib/matlab_helpers/matlab_queue.rb', line 33

def add_to_path(*args)
  args.each { |arg| @paths << arg }
end

#run!Object



22
23
24
25
26
# File 'lib/matlab_helpers/matlab_queue.rb', line 22

def run!
  set_matlabpath
  cmd = @ml_command + " -r \"#{ escape_error(to_s) }, exit\" "
  @success = run(cmd)
end

#to_sObject



18
19
20
# File 'lib/matlab_helpers/matlab_queue.rb', line 18

def to_s
  @commands.flatten.join(', ')
end