dodsonwilliam (2) [Avatar] Offline
#1
When I try and run the program included below I get:

"no such file to load -- erb/erb (LoadError)

I am running on Linux Red Hat 9 with Ruby version 1.8.4. How can I correct his problem? I thought I needed to install erb so I downloaded it and there are no instructions on how to install it. Any help greatly appreciated, thanks.


require 'rexml/document'
require "erb/erb"

print "Reading in fields file...
"

doc = REXML:smilieocument.new( File.open( "fields.xml" ) )

print "Fields file has been read, looping through classes...
"

doc.root.each_element( "class" ) { |class_obj|
class_name = class_obj.attributes() [ "name" ]
fields = []
class_obj.each_element( "field" ) { |field|
fields.push( field.text.strip )
}
erb = ERb.new( File.open( "field_class.template.java" ).read )
new_code = erb.result( binding )
print "Creating #{class_name}.java
"
File.open( "#{class_name}.java", "w" ).write( new_code )
}
dodsonwilliam (2) [Avatar] Offline
#2
Re: erb/erb (LoadError)
OK, I figured it out. I changed the line:

require "erb/erb"

to

require 'erb'

and then further down I replaced the variable ERb with ERB and then it ran correctly. Hopefully this will help others.