Ruby Single versus Double Quotes

Viewed 3043

Is there some sort of Ruby to_s method that changes a variable to a single-quoted string instead of double quotes?

Say I have

date = Time.now
date.to_s

and I want the output to be '2012-08-01 22:00:15'. How do I go about doing this? Or is there a method to convert "" strings to '' strings?

Thanks!

EDIT - More Detail

I'm using Rails to display some data in a database. I've created the @instanceVar as an array of arrays from my Controller/Model.

<% outer = [] %>
<% inner = [] %>

<% @instanceVar.each do |events| %>
  <% events.each do |event| %>
    <% inner << [event.date, event.total] %>
  <% end %>
  <% outer << inner %>
<% end %>

I need event.date to be a single quoted string.

    <% inner << ['event.date', event.total] %>

just literally adds the words event.date to the array, and

    <% inner << ["#{event.date}", event.total] %>

puts the date in double quotes.

EDIT2

<script>
  $.jqplot('trendingEvents', <%= outer %>,
  {
    #options go here
  });
</script>
2 Answers
Related