[#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:01888] Re: Scanning for comments....

From: "David Douthitt" <DDouthitt@...>
Date: 2000-03-16 15:25:38 UTC
List: ruby-talk #1888
|>>> "David Douthitt" <DDouthitt@cuna.com> 03/15/00 04:15PM >>>
|>>> Dave Thomas <Dave@thomases.com> 03/15/00 03:50PM >>>
|"David Douthitt" <DDouthitt@cuna.com> writes:
|
|> Why not use this pattern substitution (instead of gsub! and yield) -
|> 
|> line = s/[ \t]*#.*$//;
|> next if /^$/;
|> 
|> Not sure how that translates to Ruby....
|
|The s/// is a sub(/\s*#.*/, '').
|
|The only reason for the separate method is reusability: the next time
|you need to read an Oracle configuration or whatever you've got the
|useful configReader method in your toolkit.

.....and I said:

|I wasn't talking about method v. otherwise necessarily - just the guts of it.  You could just plop the core into a method, right?
|
|I would actually prefer to do this from a code-quality and code-documentation standpoint.  After all, what's this do (QUICK!) :
|
|line.gsub!(/\s*#.*/, '')
|next if (line =~ /^$/)
|
|Now, what's this do:
|
|next if line.comment?
|
|See?

Another even better idea!!!!

def class ConfigFile
   def each_line
      .... read line until non-comment, and strip comments out...
   end
end

Now to go off and do it...

In This Thread

Prev Next