Permalink
Browse files

Added block usage to Matlab::Engine.new

git-svn-id: http://matlab-ruby.rubyforge.org/svn/trunk@14 a4cadce9-4ec9-48b2-9120-f971c031a6cc
  • Loading branch information...
1 parent d779111 commit aa73d9e6ab6b24aa88fe9db8957ed624f0914a59 poogle committed Feb 21, 2008
Showing with 25 additions and 0 deletions.
  1. +5 −0 History.txt
  2. +6 −0 README.txt
  3. +14 −0 lib/matlab/engine.rb
View
@@ -1,3 +1,8 @@
+== 2.0.1 / 2008-02-21
+
+* 1 minor enhancement
+ * Added block usage to Matlab::Engine.new
+
== 2.0.0 / 2008-01-03
* 1 bug fix
View
@@ -28,6 +28,12 @@ A Ruby interface to the MATLAB interpreted language.
engine.save "/tmp/20_x_400_matrix"
engine.close
+
+ # May also use block syntax for new
+ Matlab::Engine.new do |engine|
+ engine.put_variable "x", 123.456
+ engine.get_variable "x"
+ end
== REQUIREMENTS:
View
@@ -13,6 +13,12 @@ module Matlab
# p engine.get_variable "z"
#
# engine.close
+ #
+ # # May also use block syntax for new
+ # Matlab::Engine.new do |engine|
+ # engine.put_variable "x", 123.456
+ # engine.get_variable "x"
+ # end
#
# Values are sent to and from MATLAB by calling a method on the
# engine with the variable name of interest.
@@ -28,6 +34,14 @@ def initialize(command = "matlab -nodesktop -nosplash", options = {})
load_driver(options[:driver])
@handle = @driver.open(command)
+
+ if block_given?
+ begin
+ yield self
+ ensure
+ close
+ end
+ end
end
# Sends the given string to MATLAB to be evaluated

0 comments on commit aa73d9e

Please sign in to comment.