VII.1.1.2 Using component with ruby
The file “COM/EX99_LANGS/testClaCom.rb” contains the Ruby code for automating CLA calculations. This program is very similar to the Python program:
-
At the beginning of the program, several standard packages must be loaded:
require ’Win32API’ require ’win32ole’“Win32API” is needed to create message box windows, and “win32ole” is needed for OLE automation.
-
The program defines the same three methods as the Python program in section VII.1.1.1: “id2str”, “printLamProperties” and “printLoadResponse”. These methods are nearly identical to their counterparts in the Python version.
-
In the main program, the COM component is accessed and the ClaDb database created as follows:
frpApp = WIN32OLE.new("FeResPost_3_4_0.Application") db=frpApp.newObject("ClaDb") db.readNeutral("test.ndf")(Here again, you may need to change the FeResPost version number to match the version installed on your computer.) The loop over laminate and load IDs is written as follows:
db.iter_laminateId.each do |lamId| printLamProperties(db,os,lamId) db.iter_loadId.each do |loadId| printLoadResponse(db,os,lamId,loadId,0.0,criteria) end end
Note that the window created at the end of the program may indicate that some references to COM objects have not been released. This is a known issue in Ruby’s “win32ole” extension, not in the FeResPost COM component.