I've pasted the following code in notepad:
puts ("enter a number")
x = gets.to_i
puts ("enter a second number")
y = gets.to_i
result = x + y
puts result
I've also created the following batch file:
@echo off
"C:\Users\Asus\ruby\helloworld.rb" "%1"
pause
When running the prog I get the following response in the command line:
enter a number
C:/Users/Asus/ruby/helloworld.rb:2:in `gets': Invalid argument @ rb_sysopen - $(C:\Users\Asus\ruby\helloworld.rb) (Errno::EINVAL)
from C:/Users/Asus/ruby/helloworld.rb:2:in `gets'
from C:/Users/Asus/ruby/helloworld.rb:2:in `<main>'
This works for me on windows:
Make you batch file look like:
Edit a ruby file in Notepad++ and save it. Enter the following in the dialog box from the menu "Run/Run..."
Alternatively you can call ruby directly from the Run/Run... but you will need to put a pause at the end of your script, eg:
And your code should do something like:
Once you are comfortable with that then maybe set up a Run/Run... to run Rake tasks in your project