[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:01914] Re: I'm stumped...!

From: gotoken@... (GOTO Kentaro)
Date: 2000-03-16 17:34:14 UTC
List: ruby-talk #1914
Hi,

In message "[ruby-talk:01903] I'm stumped...!"
    on 00/03/16, "David Douthitt" <DDouthitt@cuna.com> writes:

>#!/opt/ruby/bin/ruby
>
>#---------------------------------
># Oracle Specific Functions
>#---------------------------------
>
>oratab = "/etc/oratab";

This variable `oratab' is a local variable, which doesn't shared
by other class scopes, i.e., the below:

>class Oratab < ConfigFile
>   def open
>      super(oratab)
>   end

Here oratab is not defined. 
You should use a canstant (Oratab) or a global variable ($oratab). 
I would recommend to use a constant Oratab::OratabFile, that is,

  class Oratab < ConfigFile
    OratabFile = "/etc/oratab"

But the error was directly from misplace the definition. 
If you would use `Oratab.open', you have to define `Oratab.open', so:

  class Oratab < ConfigFile
    OratabFile = "/etc/oratab"

    def Oratab.open
      super(OratabFile)
    end

>   def instances
>      Oratab.open.each_line { |line|
>         data = (line =~ /^([^:]+):/)
>         yield data
>         }
>   end
>end

Hope this helps

-- gotoken

In This Thread

Prev Next