Devin Mullins
12/13/2006 2:21:00 PM
Olivia Dou wrote:
> Is there a class in the ruby lib that is equivalent to Properties class
> in Java?
If you can read something that can parse and emit Java .properties
files, then no, not in standard ruby, and a quick google doesn't find much.
You can hack something together...
IO.readlines('some.properties').reject{|l|l=~/^\s*#/}.
map{|l|l.split('=',2)}
But I'm sure that misses a whole buncha edge cases, like backslash
escaping, and Ant-style property substitution.
If you mean some way to parse/emit key/value parse from/to a
human-readable format... Hash and YAML.
Devin