From: jbritt@... Date: 2003-01-26T08:19:33+09:00 Subject: Re: datafiles as Ruby source musings > Does anybody have a nice hint or better trick to create data- or config files > readable with Ruby without having to write parsers in ruby? > > thanks, > Wilbert > A not-uncommon approach is to define a class with your global vars #---------------------------------------- # file config.rb class Config VAR=true OTHERVAR=false YETANOTHER=true # Use some conditional logic to define a config constant ... winroot = "" /mswin/ =~ RUBY_PLATFORM ? winroot = "C:/" : winroot = "" BASE_PATH = "#{winroot}/home/foobar" end #---------------------------------------- and then just require this file elsewhere #---------------------------------------- # File my_test.rb require 'config' my_var = Config::VAR my_other_var = Config::OTHERVAR my_dev_path = Config::BASE_PATH #---------------------------------------- James