Re: Using Ruby to read .properties file

None that I know of without writing code - but there isn’t much to it.
Try this:

def load_properties(properties_filename)
properties = {}
File.open(properties_filename, ‘r’) do |properties_file|
properties_file.read.each_line do |line|
line.strip!
if (line[0] != ?# and line[0] != ?=)
i = line.index(‘=’)
if (i)
properties[line[0…i - 1].strip] = line[i + 1…-1].strip
else
properties[line] = ‘’
end
end
end
end
properties
end

Unashamedly taken from BigBold - Informasi Tentang Bisnis dan Marketing

Thanks a lot for the code

sanchit

“Lock Stephen” [email protected]
06/06/2006 07:29 PM
Please respond to
[email protected]

To
[email protected] (ruby-talk ML)
cc

Subject
Re: Using Ruby to read .properties file

None that I know of without writing code - but there isn’t much to it.
Try this:

def load_properties(properties_filename)
properties = {}
File.open(properties_filename, ‘r’) do |properties_file|
properties_file.read.each_line do |line|
line.strip!
if (line[0] != ?# and line[0] != ?=)
i = line.index(‘=’)
if (i)
properties[line[0…i - 1].strip] = line[i + 1…-1].strip
else
properties[line] = ‘’
end
end
end
end
properties
end

Unashamedly taken from BigBold - Informasi Tentang Bisnis dan Marketing