Trying to follow the code on chapter 4 ( 
http://poignantguide.net/ruby/chapter-4.html ) and I cannot get the 
section called  Making the swap'c code to work.

this is saved as wordlist.rb:

 code_words = {
   'starmonkeys' => 'Phil and Pete, those prickly chancellors of the New 
Reich',
   'catapult' => 'chucky go-go', 'firebomb' => 'Heat-Assisted Living',
   'Nigeria' => "Ny and Jerry's Dry Cleaning (with Donuts)",
   'Put the kabosh on' => 'Put the cable box on'
 }

and this as wordtest.rb:

require 'wordlist'

 # Get evil idea and swap in code words
 print "Enter your new idea: "
 idea = gets
 code_words.each do |real, code|
   idea.gsub!( real, code )
 end

 # Save the jibberish to a new file
 print "File encoded.  Please enter a name for this idea: "
 idea_name = gets.strip
 File::open( "idea-" + idea_name + ".txt", "w" ) do |f|
   f << idea
 end

When I run this from the command line (on WinXP) I enter:

ruby wordtest.rb

The program runs asks for an input then blows up saying that undefined 
local variable code_words on line 7 in wordtest.rb.

I have followed everything and the only way I can get a result it to 
place the whole code_words has directly into wordtest.rb. So I think it 
has something to do with the require statement but still cannot get 
anything to work.

Thanks for your help.

-- 
Posted via http://www.ruby-forum.com/.