What about readlines.last?
On Feb 1, 7:40 pm, Richard Schneeman <rails-mailing-l...@andreas-
s.net> wrote:
> Thanks that did the trick. Do you know if there is an easy way to get
> the last result, or everything without having to do so many "gets"? I
> tried .each and readlines but with not much success. Or at least a way
> to determine when the last line has been "get"en without error-ing out?
>
> >> max = IO.popen("maxima", "w+")
> => #<IO:0x201bccc>
> >> max.puts "1+1;"
> => nil
> >> max.gets
>
> => "Maxima 5.15.0http://maxima.sourceforge.net\n">> max.gets
>
> => "Using Lisp SBCL 1.0.17\n">> max.gets
>
> => "Distributed under the GNU Public License. See the file COPYING.\n">>
> max.gets
>
> => "Dedicated to the memory of William Schelter.\n">> max.gets
>
> => "The function bug_report() provides bug reporting information.\n">>
> max.gets
> => "(%i1) \n"
> >> max.gets
>
> => "(%o1) 2\n">> max.puts "1+9;"
> => nil
> >> max.gets
> => "(%i2) \n"
> >> max.gets
>
> => "(%o2) 10\n"
>
> >> max.gets
>
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---