It won’t be about performance. It will be about documentation. Ruby is beautiful language and it gives a lot of fun when coding. But there is some wide gap between tutorials and standard library documentation. RDoc pages are very useful when You know exactly what to search for… But in case You know more that after average tutorial or basic book (like Programming in Ruby) it is sometimes hard to find useful information in short time. Lucky we have Google…
Let examine Net::HTTP.start method. From it’s documentation (search for start (Net::HTTP) in Methods window and follow link – it is example why frames in HTML should be banned) would You know how to set port to which it should connect?
Opens TCP connection and HTTP session.
When this method is called with block, gives a HTTP object to the block and closes the TCP connection / HTTP session after the block executed.
When called with a block, returns the return value of the block; otherwise, returns self.
So how to connect to non standard port? And the answer is just like that:
conn = Net::HTTP.start('localhost', 81)
That’s it. And I was searching long, long time…
Could someone recommend good book about Ruby (not language itself, since it is very well described in Programming Ruby: The Pragmatic Programmers’ Guide, Second Edition, I have only remarks to standard library description, rest is top-notch) ?
Leave a Reply