From: David Douthitt Date: 2000-03-16T11:09:24-06:00 Subject: [ruby-talk:01903] I'm stumped...! Yes, I DO read the Ruby User Guide.... Yes, I DO read the Ruby Manual..... But STILL I have many questions............. What is happening in this code? The code runs fine, but the commented out code generates the errors shown above each, and I don't know why. #!/opt/ruby/bin/ruby #--------------------------------- # Oracle Specific Functions #--------------------------------- oratab = "/etc/oratab"; class ConfigFile < File def each_line super { |line| next if (line =~ /^(#|[ \t]*$)/); line.gsub!(/[ \t]+#.*$/, ""); yield line; } end alias each each_line; end class Oratab < ConfigFile def open super(oratab) end def instances Oratab.open.each_line { |line| data = (line =~ /^([^:]+):/) yield data } end end class Instance def log (str, pri) `/bin/logger -t oracle -p #{pri} "#{str}"` end end #--------------------------------- # Program #--------------------------------- ConfigFile.open(oratab).each_line { |line| line.chomp!; print line, "\n"; } #./ruby.functions:43:in `open': wrong # of arguments (0 for 1) (ArgumentError) # from ./ruby.functions:43 #Oratab.open.each_line { |line| # line.chomp!; # print line, "\n"; # } #./ruby.functions:57: undefined method `log' for Instance:Class (NameError) #Instance.log("test", "info"); #./ruby.functions:51: undefined method `instances' for Oratab:Class (NameError) #Oratab.instances { |inst| # print inst, " "; # }