Archive for the ‘Ruby’ Category

Parse operating system commands from ruby.

Sunday, May 25th, 2008

If you want to execute operating system level commands from ruby the solution is below. it’s quite easy and interesting. What would i say about the beauty of ruby here, Just thanks to ruby creators.

irb(main):001:0> system('ls -l')
total 2240
drwxr-xr-x 15 tarun tarun   24576 2008-05-21 01:33 git-1.5.5.1
-rw-r--r--  1 tarun tarun 2002900 2008-04-21 03:47 git-1.5.5.1.tar.gz
-rw-r--r--  1 tarun tarun  252308 2008-04-21 04:05 git-manpages-1.5.5.1.tar.gz
drwxr-xr-x  3 tarun tarun    4096 2008-05-21 09:42 ruby
=> true
irb(main):002:0>

Radiant on ubuntu 7.10 box

Tuesday, May 20th, 2008

Today i found an excellent CMS based upon RubyOnRails, It’s radiant. I installed it on my ubuntu 7.10 box successfully. It was really great experience for me. I am learning ruby yet but would like to contribute for radiant development soon. Anyway will let you know when i’ll be able to release some thing useful in the favour of radiant. I would like to assist if you have any issue with radiant installation. I may help you.

One more behaviour of ruby

Sunday, May 18th, 2008

Today while working with ruby i noticed one more surprising behaviour of ruby.

1
2
arg1="Ruby", arg2="On", arg3="Rails" 
puts "#{arg1},#{arg2},#{arg3}"

What should be the results?
Well i was expecting to be printed like “Ruby”,”On”,”Rails” but the result was “RubyonRails”, “On”, “Rails”
To understand this behaviour i did some more experiments in “irb”

1
2
3
puts arg1.class.to_s    # result  Array 
puts arg2.class.to_s    # result String 
puts arg3.class.to_s    # result String

Now the question is, Why arg1 is interpreted as an array? and why not the arg2 ?