From: Hugh Sasse Staff Elec Eng Date: 2004-04-30T02:30:54+09:00 Subject: Should StringIO support to_str ? How is one supposed to get a string from a StringIO? If it is an extension of string should it not support the new to_str method? brains hgs 38 %> ./!$ ./StringIOtest.rb "#" "#" ./StringIOtest.rb:12: undefined method `to_str' for # (NoMethodError) brains hgs 39 %> ruby --version ruby 1.8.1 (2003-12-25) [sparc-solaris2.9] brains hgs 40 %> cat ./StringIOtest.rb #!/usr/local/bin/ruby require 'stringio' string = "a string." stream = StringIO.new(string) stream << ' More text' p stream.inspect p stream.to_s p stream.to_str brains hgs 41 %> The result of p looks add brains hgs 42 %> ruby -e "x = 'y'; p x.inspect" "\"y\"" brains hgs 43 %> is more what I was expecting -- i.e the StringIO's contents. Hugh