in my recent post, i have posted how to make sure that you have Ruby machine on your system. now let’s go ahead, to see what the wonder full of Ruby. may be you need to create a folder named ‘pickaxe’ (or what ever you want) on your directory. then let’s open our terminal then placed on your ‘pickaxe’ folder.
$ cd ~/pickaxe
so, what the next? well one you have opened your terminal. you can back to your desktop and go to your ‘pickaxe’ folder then create new file calling it ‘greeting.rb’ (or what ever you want). then open it on your favorite text editor like notepad ++. then we started to code.
puts “Hello world, i’m Ruby programmer”
puts “It is now #{Time.now}”
when you have passed all, you can started to run with your terminal by typing this command
~ /pickaxe$ ruby greeting.rb
and you will see the result must be like this
Hello world, i’m Ruby programmer
It is now 2013-10-19 01:17:38 +0700
oh, no! are you can’t see that? go back and check your script slowly, one by one. make sure that you have typed correctly. then try to run again.
aye, let’s see what the simple thing that we’ve done.
1. puts “something here” => thats command will order to our machine for showing something to our screen.
2. #{Time.now} => the ruby’s function that allow you to see the current local time on your machine setting.
well, if you find some embarrassing with your first Ruby, you may leave comment, and i hope, i can solved your case.