Tag Archives: RubyLearning

Online ruby Programming useful website links

1. Ruby http://tryruby.org2. Hpricot http://hpricot.com3. Regular expressions http://rubular.com4. Exceptions http://hoptoadapp.com/5. Application Performance http://newrelic.com6. Ruby Doc http://www.ruby-doc.org/7. Rails API http://api.rubyonrails.org/8. Ruby gems sources http://rubyforge.org / http://gems.github.com / http://gemcutter.org9. Listing remote gems from source gem list –remote –source http://gems.github.com10. List of Rails Plugins http://wiki.rubyonrails.org/rails/pages/Pluginshttp://www.agilewebdevelopment.com/plugins Advertisements

Posted in Ruby | Tagged | Leave a comment

Dynamic creation of variables in ruby

1. To create local variables in ruby dynamically. Use eval method in ruby ree-1.8.7-2010.01 > eval(“local=4”)  => 4  ree-1.8.7-2010.01 > p local 4 ree-1.8.7-2010.01 > eval(“local_#{1}=4”)  => 4  ree-1.8.7-2010.01 > puts local_1 4 2. To create & get instance variables … Continue reading

Posted in Ruby | Tagged | Leave a comment

Eval method in ruby

Eval method in ruby executes string/expression passed as parameter. Example: ree-1.8.7-2010.01 > eval(“5+3”)  => 8  ree-1.8.7-2010.01 > eval(“a=5”)  => 5  ree-1.8.7-2010.01 > eval(“b||=a”)  => 5  Its part of ruby meta-programming and not recommended approach unless there is no any alternative to do.

Posted in Ruby | Tagged , | Leave a comment

RPCFN#3 Short-circuit

It was great to see so many solutions for the problem statement I had set. After an initial ‘shock’ from all electrical engineers, the problem was clearly understood as a variant of the ‘shortest path algorithm’. I hope I was … Continue reading

Posted in Ruby on Rails | Tagged , | 5 Comments