C
CSZ
Hi !
I'm going my way through a Ruby online tutorial right now and i have
following problem:
I have two files. File one:
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'
}
makeSwamp.rb
#!/usr/bin/env ruby
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:pen( "idea-" + idea_name + ".txt", "w" ) do |f|
f << idea
end
When i execute the makeSwamp.rb file i can enter a "new idea" but than i
get:
/makeSwamp.rb:8: undefined local variable or method `code_words' for
main:Object (NameError)
(line 8 is: code_words.each do |real, code| )
Why ??? I've run kdiff and its exactly as in the tutorial... Maybe its
just to late for me..
I'm going my way through a Ruby online tutorial right now and i have
following problem:
I have two files. File one:
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'
}
makeSwamp.rb
#!/usr/bin/env ruby
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:pen( "idea-" + idea_name + ".txt", "w" ) do |f|
f << idea
end
When i execute the makeSwamp.rb file i can enter a "new idea" but than i
get:
/makeSwamp.rb:8: undefined local variable or method `code_words' for
main:Object (NameError)
(line 8 is: code_words.each do |real, code| )
Why ??? I've run kdiff and its exactly as in the tutorial... Maybe its
just to late for me..