0

I'm not sure why I get this error, since it does seem to be an array in Ruby 1.8.7.

Here is the relevant code:

rows.each_with_index do |row, index|
    if (index == 0) then
        log "Found the following slow statements (took over #{slow_query_threshold} seconds):"
    end
    row_data = row.strip().split('|')
    connections = row_data[1].split(', ')
    n_more = '... and #{connections.length - 3} more' if connections.length > 3
    log %{[#{row_data[0]}] on #{connections.take(3).join(', ')} #{n_more}}
end

Which gives me this error:

2013-04-10T05:36:45.04Z : Found the following slow statements (took over 5.0 seconds):
/myscript.rb:111: undefined method `take' for ["App15(28.39sec)"]:Array (NoMethodError)
     from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `each_with_index'
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Benbob
  • 13,876
  • 18
  • 79
  • 114

1 Answers1

0

You must be running on 1.8.6. Upgrade, or require 'backports/1.8.7/enumerable/take'

Marc-André Lafortune
  • 78,216
  • 16
  • 166
  • 166
  • Was running on 1.8.5 because the #! in my script pointed to a different version than `which ruby`. – Benbob Apr 10 '13 at 23:04