title: Best way to execute math expression string in ruby?
body: <p>I want to execute math expression which is in string like this sample strings:</p>
  <ol>
  <li><code>A = &quot;23&gt;=34&quot;</code></li>
  <li><code>B = &quot;77&lt;90&quot;</code></li>
  <li><code>C = &quot;33&gt;77&quot;</code></li>
  </ol>
  <p>and I want some function like <code>if exec_string(A)</code> which should return true or false.</p>
  <p>Currently I am using this method:</p>
  <pre class="lang-rb prettyprint-override"><code>    rest = --- # I am splitting the string in to three(L- as left number cmpr- as compare and R- as right number )
      class_name.calc(rest[0],rest[1],rest[2])
      def self.calc(L,cmpr,R)
          case cmpr
            when &quot;&lt;&quot;
              if L.to_i &lt; R.to_i
                return true
              end
             ....
             ....
             ....
           end
      end 
  </code></pre>
  <p>Which could not handle lot of cases. Any help?</p>