I have a string in Ruby on which I\'m calling the strip method to remove the leading and trailing whitespace. e.g.
s = \"12345 \" s.strip
H
You can use method try from ActiveSupport (Rails library)
try
gem install activesupport require 'active_support/core_ext/object/try' s.try(:strip)
or you can use my gem tryit which gives extra facilities:
gem install tryit s.try { strip }