 <pre><code>X.each do |key, value| value.class == BigDecimal ? puts value.to_s : puts value end </code></pre> <p>or </p> <pre><code>X.each { |key, value | value.class == BigDecimal ? puts value.to_s : puts value } </code></pre> <p>Check out the ternary operator. </p> <p>Edit:</p> <p>Also in regards to your edited question requesting one string: </p> <p><code>new_array = X.map {|object| object.class == BigDecimal ? object.to_s : object }</code> then turn it into a string with <code>new_array.join("")</code></p>