From: Derril Lucci on 8 Apr 2010 19:21 Hi everyone, I am writing a program for my research that uses configuration files. I was curious how to import these files into my ruby program. Any help would be appreciated. If it helps, I am running ruby 1.9. Cheers, dlucci -- Posted via http://www.ruby-forum.com/.
From: gf on 8 Apr 2010 21:42 What kind of configuration files? What format are they in? YAML, XML? On Apr 8, 4:21 pm, Derril Lucci <derril.lu...(a)gmail.com> wrote: > Hi everyone, > I am writing a program for my research that uses configuration files. > I was curious how to import these files into my ruby program. Any help > would be appreciated. If it helps, I am running ruby 1.9. > > Cheers, > dlucci > -- > Posted viahttp://www.ruby-forum.com/. > > -- > Subscription settings:http://groups.google.com/group/ruby-talk-google/subscribe?hl=en
From: Derril Lucci on 8 Apr 2010 21:53 Well, I am not too educated in configuration files. I was going to just write it in ruby (thats the language I am working in). The configuration file is being used to specify intervals in time. My project is generating a report for SysAdmins and this will allow them to specify the interval at which they want the reports to be compared. Getting back to the main problem, I had thought it was either "require" or "include", but both of those proved fruitless. Hope this info helps. Cheers, dlucci -- Posted via http://www.ruby-forum.com/.
From: Mario Antonetti on 8 Apr 2010 22:55 [Note: parts of this message were removed to make it a legal post.] If you could include a sample of the files' contents, it would be helpful. require is used to access ruby libraries. What you are looking for is the File class. For example File.open('config.txt').each do |line| puts line end will spit out each line of a file. On Thu, Apr 8, 2010 at 8:53 PM, Derril Lucci <derril.lucci(a)gmail.com> wrote: > Well, I am not too educated in configuration files. I was going to just > write it in ruby (thats the language I am working in). The > configuration file is being used to specify intervals in time. My > project is generating a report for SysAdmins and this will allow them to > specify the interval at which they want the reports to be compared. > Getting back to the main problem, I had thought it was either "require" > or "include", but both of those proved fruitless. Hope this info helps. > > Cheers, > dlucci > > -- > Posted via http://www.ruby-forum.com/. > >
From: Robert Klemme on 9 Apr 2010 06:03 On 04/09/2010 03:53 AM, Derril Lucci wrote: > Well, I am not too educated in configuration files. I was going to just > write it in ruby (thats the language I am working in). The > configuration file is being used to specify intervals in time. My > project is generating a report for SysAdmins and this will allow them to > specify the interval at which they want the reports to be compared. > Getting back to the main problem, I had thought it was either "require" > or "include", but both of those proved fruitless. Hope this info helps. The simples approach is to use "load": load File.join(ENV['HOME'], '.myconfrc') file ~/.myconfrc: $interval = 15 Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/
|
Pages: 1 Prev: [QUIZ][SUMMARY] Distinct Sets (#225) Next: read and write stock prices to file using arrays |