The second example, defined in file “testCla2.rb” illustrates the use of iterators. For each laminate defined in a ClaDb, several properties are printed. These properties are printed in several directions by rotations of . Part of the program is reproduced below:
def diagnostic(edfName,os)
db=ClaDb.new
db.Id="testDB"
db.readEdf("test.edf")
db.each_laminate do |lamId,lam|
(0..360).step(30) do |i|
theta=1.0*i
os.printf("\nlaminate = \"%s\" -- theta = %g\n\n",lamId.to_s,theta)
os.printf("\n Stiffness matrix : \n\n");
lam.write_ABBD(os,theta)
os.printf("\n");
...
end
end
end
os=File.open("test.txt","w")
diagnostic("test.edf",os)
os.close