4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/magma.rb', line 4
def magtutor
tutorline=<<-'FINISH'
Hello there, and welcome to Magma. This is Magma tutor. It is a built-in tutorial to help you understand Magma. Let us begin.
=============1. Setup=============
To start up Magma in a Ruby script, add a line to the top of the script, like this:
require "magma"; #< Semicolon unnessary, but helps in .min.rb files
After that line, we must test magma. Check the value of the Magma? environment variable to do so. If the value returned is true, then magma is ready. If the value returned is nil, then Magma has an error, and is not ready. Use this code to get a boolean (true or false) value for if Magma is ready:
if (ENV["magma?"]==true) then;return true; else; return false; end
Now that we know that magma is ready, we can start! Proceed to part 2.
=============2. CommandLine========
It is important to know that Magma is completely Ruby code. But using Magma, you can run shell scripts! Using magma, you can execute shell script commands, and see and check their outcomes. A built-in object called CommandLine exists when Magma is ready. This object contains methods for accessing command line info. Try running this:
CommandLine.execute('ls')
If you are familiar with the Unix ls command, remember that it lists all files in the current directory. When running the code above, you will see the files, in Ruby! It will also return the files, [but in an unorganized string, which can be organized into an array later]. Also, if you would like to find what Command Line Viewer program (aka Command Prompt, Mac Terminal, iTerm, etc) the user is running, use this command:
CommandLine.program()
FINISH
puts tutorline; puts "\n\n"; return tutorLine
end
|