greg.kujawa
3/21/2006 5:46:00 PM
Here's something that works if you define things in terms of a Ruby
module in the wordlist.rb file:
wordlist.rb
---------------
module Wordlist
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'
}
end
And then here's the other test file:
wordtest.rb
----------------
require 'wordlist'
# Get evil idea and swap in code words
print "Enter your new idea: "
idea = gets
Wordlist::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