I am very new to ruby (but a retired experienced C programmer) and am
getting buried in the amount of documentation available. Have been
unable to find an answer to this question, but perhaps do not understand
the concepts involved enough to search correctly. Given this code
In interactive ruby can I suppress the output produced by
Hpricot.XML(open(url))
is this the stdout stream or is it something else? At completion the
HTML is in the doc object so is there any need for it to also be
displayed. Perhaps the object has a means of suppressing the data being
loaded?
I am working with web pages and a very large amount of data is involved.
When I mark and copy the irb window to a file to do searches on the data
I have a lot of unneeded and duplicated data. Perhaps there are IRB
parameters to resolve this
I know I can redirect to a file then use the file (but still have same
problem when opening file for processing), but what I would like to do
is the equivalent of redirecting stdout (if it is stdout) to NULL on a
per line basis.
What you could do is simply append "; nil" to the end of the line:
irb(main):001:0> s = "some really, really long string" ; nil
=> nil
-Justin
···
On 10/03/2010 07:33 PM, Don Norcott wrote:
I am very new to ruby (but a retired experienced C programmer) and am
getting buried in the amount of documentation available. Have been
unable to find an answer to this question, but perhaps do not understand
the concepts involved enough to search correctly. Given this code
In interactive ruby can I suppress the output produced by
Hpricot.XML(open(url))
is this the stdout stream or is it something else? At completion the
HTML is in the doc object so is there any need for it to also be
displayed. Perhaps the object has a means of suppressing the data being
loaded?
I am working with web pages and a very large amount of data is involved.
When I mark and copy the irb window to a file to do searches on the data
I have a lot of unneeded and duplicated data. Perhaps there are IRB
parameters to resolve this
I know I can redirect to a file then use the file (but still have same
problem when opening file for processing), but what I would like to do
is the equivalent of redirecting stdout (if it is stdout) to NULL on a
per line basis.
Thanks these all did the trick. I especially like the toggle.
However even after finding the solution I still could not find where any
of this is documented.
Sure it is. It is documented everywhere. From the pickaxe:
"irb will display the value of each expression as you complete it. For instance: [...irb examples...]"
I would like to see an explanation of "string"; null.
nil, not null.
What more explanation do you want to see, and where? If you have a lot of output from an expression, you augment that expression so that it isn't the final result.
I find that adding only a semicolon (no nil)does the trick
doc = Nokogiri::HTML(open(url)); # produces no display
No, it doesn't. Look at my prompts:
501 % irb
>> "blah"
=> "blah"
>> "blah";
?>
You've told ruby (irb actually) that there is more coming. That's all.
Can you point me to some documentation than may explain the solutions,
so I know where to look next time.
Again. Everywhere. The pickaxe has an entire chapter on the subject.
Sorry I seem to hit a sore spot. I have no problem with the
answers/explanations given. I have read multiple tutorials but they are
not a good reference source. I have downloaded both core and std
library documentation but it is difficult to retrieve info from as you
must know what your after before you start looking.
I guess I am looking for a non-HTML document that contains the Ruby
spec(like the 'ANSI C Standard' documentation). If such a creature
exists I would appreciated a pointer to it.
I probably did not phrase my original query properly. It had at least
as much to do with finding the documentation that would answer my
questions as opposed to simply looking for an answer.
I guess I am looking for a non-HTML document that contains the Ruby
spec(like the 'ANSI C Standard' documentation). If such a creature
exists I would appreciated a pointer to it.
--
(+61 4) 0679 5734 :: skype: govirtual.com.au :: チェックアウトが、Jingle だ!
::It's a Jingle Out There!
There is [1], but like the ANSI C standard, it only goes over the core language. I don't think there is an effort to define a specification for the ruby standard library.
Sorry I seem to hit a sore spot. I have no problem with the
answers/explanations given. I have read multiple tutorials but they are
not a good reference source. I have downloaded both core and std
library documentation but it is difficult to retrieve info from as you
must know what your after before you start looking.
I guess I am looking for a non-HTML document that contains the Ruby
spec(like the 'ANSI C Standard' documentation). If such a creature
exists I would appreciated a pointer to it.
I have read multiple tutorials but they are
not a good reference source. I have downloaded both core and std
library documentation but it is difficult to retrieve info from as you
must know what your after before you start looking.
That's the free 1st edition, written for ruby 1.6, but pretty much all
applies to 1.8. I think the book source is floating around somewhere,
and somebody may have made a PDF of it.
Otherwise, it's certainly worth buying the PDF of the 2nd edition. I
would not buy the 3rd edition unless you want to deal with the issues
around ruby 1.9.