From: Jonathan Castello Date: 2009-09-22T11:21:24+09:00 Subject: Re: redirect STDOUT to function? --_5cc4174c-464b-4247-95df-1d0cb6825b8d_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hmm=2C what do you mean by "backed by the function you want"? My whole prob= lem is that I don't know what function(s) to redefine in order for the obje= ct to work reliably. For example=2C do all of the methods rely on just one = to access the data directly=2C or are there multiple such methods I'd need = to account for? > Date: Tue=2C 22 Sep 2009 11:08:42 +0900 > From: kbloom@gmail.com > Subject: Re: redirect STDOUT to function? > To: ruby-talk@ruby-lang.org >=20 > On Tue=2C 22 Sep 2009 10:07:16 +0900=2C Jonathan Castello wrote: >=20 > > Hello=2C > > I'm using Ruby as a scripting language for a program that supports the > > WSH scripting interface=2C and I have a small problem: 'puts' and other > > output functions don't work (because STDOUT is invalid)=2C as with 'get= s' > > (but with STDIN). I'd like to redirect all accesses to STDOUT and STDIN > > to my own functions=2C which would handle the IO through the main > > application's scripting interface. I know that $stdout and others can b= e > > reassigned to other IO objects=2C but I haven't yet found a way to > > reliably redirect through a function instead. Of course=2C this is > > probably because I'm relatively new to Ruby. Does anyone know how I > > could do something like this?~Jonathan Castello >=20 > Create a brand new IO object that's backed by the function you want.=20 > (Maybe a thread and a StringIO would do the trick.) >=20 > --Ken >=20 > --=20 > Chanoch (Ken) Bloom. PhD candidate. Linguistic Cognition Laboratory. > Department of Computer Science. Illinois Institute of Technology. > http://www.iit.edu/~kbloom1/ >=20 >=20 _________________________________________________________________ Bing brings you health info from trusted sources. http://www.bing.com/search?q=3Dpet+allergy&form=3DMHEINA&publ=3DWLHMTAG&cre= a=3DTXT_MHEINA_Health_Health_PetAllergy_1x1= --_5cc4174c-464b-4247-95df-1d0cb6825b8d_--