I'm currently trying to follow a tutorial on web scraping and have been receiving a ruby error message "Errno::ENOMEM: Not enough space". I've found a workaround from http://bugs.ruby-lang.org/issues/show/1063 but I was wondering if there is a more permanent solution. I'm using ruby 1.8.7 (2010-12-23 patchlevel 330) [i386-mingw32] and I'm not in a position to update to a new version which I suspect would fix this problem. The issue only appears when I try to get larger pages.
Current Solution:
class String
def to_2d_array(value)
unpack("a#{value}"*((size/value)+((size%value>0)?1:0)))
end
end
class << $stdout
alias old_write write
def write(a)
a.to_s.to_2d_array(1024).each{|little| old_write little}
end
end
To fix my problem I've added:
class String
def to_2d_array(value)
unpack("a#{value}"*((size/value)+((size%value>0)?1:0)))
end
end
class << $stdout
alias old_write write
def write(a)
a.to_s.to_2d_array(1024).each{|little| old_write little}
end
end
To my irb.rb file after the last end.