------ art_58957_24156999.1155392449364 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello, On 8/12/06, ClassRubyExceptionHandline <jctown / nb.sympatico.ca> wrote: > > As I make my way through the Pragmatic Programmer's Guide I am puzzled > by the following issue: > > If I type in a Ruby program such as > > class Song > def initialize(name, artist, duration) > @name ame > @artist rtist > @duration uration > end > end > > And save it as Song.rb in a directory on my hard drive reserved for > Ruby code, I wonder how I can use it from irb, if possible. I know > that I can type in each line of the .rb program within irb and have it > work when I do song ong.new("Bicylops", "Fleck", 260) > But if I attempt to type this in from irb after defining the class in a > separate .rb file I get > irb(main):001:0> song ong.new("Bicylops", "Fleck", 260) > NameError: uninitialized constant Song > from (irb):1 > from :0 > > What I would like to know is, how can I use Ruby Programs which are > already created as source within irb... or is there a better way to run > ruby programs > > > You can use require. Example: require 'path/to/song' Michael Guterl ------ art_58957_24156999.1155392449364--