Advertisement

11.08.2008 at 03:03PM PST, ID: 23888280
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.1

How to trigger commands in ruby read from an external file?

Asked by ignusb in Ruby Scripting Language, Scripting Languages

Tags:

This is purely a self learning exercise, I'm not sure whether this is going to be possible or not, though I'm sure it would allow for some great flexibility in future code.

What I want, is to load a txt file in, and execute it line by line as if it were ruby code, for example, instead of this:

#Note: This script from Gertone, from my last question.
def method1(var1, var2, var3, var4)
  puts var1
  puts var2
  puts var3
  puts var4
ed

inFile = File.open("variables.txt", "r")
vars = {}
inFile.readlines().each do |line|
  line.scan(/^(\S+)\s*=\s*(\S+).*$/) do |key,val|
    vars[key] = val
     end
  end
inFile.close
method1(vars["var1"],vars["var2"],v]ars["var3"],vars["var4"])
#End ruby script

Which outputs:
value1
value2
value3
value4

I'd like to do the same thing, but instead of just reading the variable from the text file using a regex, to execute the text file as if it were a ruby script, i.e. if the text file was:

#begin txt file
var1 = value1
var2 = value2
var3 = value3
var4 = value4
puts var1
puts var2
puts var3
puts var4
#end txt file

For the ruby script to load the text file then execute it.

Is this possible in a scalable manner?

As a note, this is the way I attempted it so far, which I didn't expect to work.. it met expectations:

#Begin Ruby Script
def runFile(mFileName)
  inFile = File.new(mFileName, "r")
  inFileC = inFile.readlines(rFileName)
  inFile.close
  return inFIleC
end

commands = runFile(input.txt)
commands.each do |i|
  i
end
#End Ruby ScriptStart Free Trial
[+][-]11.09.2008 at 05:45PM PST, ID: 22918663

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]11.09.2008 at 10:49PM PST, ID: 22919524

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.10.2008 at 12:16PM PST, ID: 22925145

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.10.2008 at 10:03PM PST, ID: 22928008

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.11.2008 at 01:43PM PST, ID: 22934661

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.11.2008 at 01:53PM PST, ID: 22934749

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.11.2008 at 10:04PM PST, ID: 22937170

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Ruby Scripting Language, Scripting Languages
Tags: Ruby
Sign Up Now!
Solution Provided By: fridom
Participating Experts: 1
Solution Grade: B
 
 
[+][-]11.13.2008 at 01:05PM PST, ID: 22954571

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080924-EE-VQP-38 - Hierarchy / EE_QW_2_20070628