265273-280424

265100-268253 subjects 265509-374549

Emulating a Groovy feature?
265273 [lists@so rc ] Guys,
+ 265274 [fwmailinglis] charset="US-ASCII"
+ 265275 [fxn@ha hr f.] class NilClass
| 265277 [celtic@sa ry] The only problem I can see here is that it's not quite optional.
| 265280 [fxn@ha hr f.] Yeah, that's the basic technique.
+ 265276 [dave@bu t. d] irb(main):001:0> def nil.method_missing(*_) end
+ 265283 [apeiros@gm .] Good to see that I'm not alone on this :)
+ 265478 [shortcutter@] Try this in IRB
  265479 [shortcutter@] x = foo.bar.baz rescue nil
  280151 [cutter38@gm ] Interesting thread....glad someone else has hit this need.
  + 280158 [jameskilton@] ...
  + 280167 [shortcutter@] The value of the expression is replaced by the value of the expression
    280168 [fedzor@gm il] Begin-Rescue-End blocks tend to slow things down significantly - does
    280295 [lkmlists@lu ] Sebastian Delmont did some benchmarking on this last year.
    280388 [charles.nutt] It slows down JRuby a bit more than Ruby 1.8, unfortunately, because of
    280389 [charles.nutt] Actually, it just occurred to me that this is entirely a factor of local
    280424 [lists@so rc ] You mean the one line rescue syntax mentioned before? Interesting, I

Named Constructor Idiom in Ruby?
265284 [celtic@sa ry] I'm almost certain there's a good way to do this, but I seem to have
+ 265285 [apeiros@gm .] # somewhat contrieved example
+ 265286 [stefano.croc] You need to make the new class method of class A private. Then, you implement
| + 265288 [celtic@sa ry] Exactly what I needed, both Stefan and Stefano! Thanks very much. :)
| + 265477 [shortcutter@] irb(main):020:0> a1 = A.special_method_1
+ 265481 [dan@fl en ra] You have some good answers, but here is yet another way that is quite

How do you post SMS messages on a website?
265292 [rsylvesterl-] I am developing a website with Ruby that will integrate SMS messaging.
+ 265299 [kovaltaras@g] Try http://zong.com
+ 265590 [dido.sevilla] What country are you in, and what is the scope (e.g. local, regional,national, international, or global) of the SMS messages you want to beable to receive? A large amount of messages is still a vague term. Upto about a thousand messages a day (mobile originated, with noresponse in return) may still be doable with a GSM modem coupled toKannel (http://www.kannel.org). For traffic volumes larger than this,or if you want to send SMS messages out, either in response or as amobile terminated service (e.g. to send updates to certain users), orif you want your service to be international or global in scope youwill need a real SMS gateway.

YAML and NArray
265294 [martin@sn wp] In the past week, I've been exploring a little problem that by
265396 [martin@sn wp] And this is what I get for posting something other than the exact code

Execute ruby commands in a program
265301 [h4z3@th -c r] Ok so lets say i have a program, And within the program i call a command
+ 265311 [wade.christo] Um, this sounds like 'irb'.  Depending on what OS you're on and how
+ 265317 [martin@sn wp] I have a bit of trouble understanding what it is you want to have
  265320 [h4z3@th -c r] Sorry its quite hard to explain, Its not IRB, because i want to actually
  265323 [dangerwillro] look up eval
  265326 [h4z3@th -c r] Thanks, i looked it up and coded something pretty much the same except
  265388 [overlord@gm ] What did you expect it to print?

Is this the perfect regex for validating first & last names?
265303 [promos@bu ch] Perhaps a fairly bold statement, coming from a novice regex'er.   :)
+ 265307 [urban@be to ] Are you really sure you want to ask a PHP question in a Ruby forum? I
+ 265316 [martin@sn wp] I don't know PHP regular expressions, but a bit of googling suggests
+ 265319 [alec@ar ro s] <promos@burchwoodusa.com> writes
+ 265357 [aledonne.lis] Most assumptions about names turn out to be wrong.

Re: Is this the perfect regex for validating first & last na
265304 [promos@bu ch] Well, shucks.  I missed the hyphenated last name condition.  Hillary
265302 [promos@bu ch] Posted via http://www.ruby-forum.com/.
265306 [promos@bu ch] Well, so much for testing my own code.   "zá" fails.  All the diacritics
265310 [promos@bu ch] Actually, it's a regex question.   Lots of regex questions and answers
265312 [apeiros@gm .] Just that ereg* is not pcre. There is no equivalent in ruby to the ereg*
265314 [promos@bu ch] Ok then.  I'll find the proper resource.   Thanks.
265365 [promos@bu ch] HA HA.   Seeing as there are so few, I think I'll copy those names into
265371 [dangerwillro] www.regexlib.com

[ANN] assert_hpricot
265305 [phlipcpp@ya ] Here's a blog entry on how to use Why's Hpricot library inside assertions,

[ANN] launchy 0.2.1 Released
265327 [jeremy@hi eg] launchy version 0.2.1 has been released.

Adding to an array question
265328 [coreyhaines@] I need to add a string to the end of an array count number of times. I
+ 265361 [apeiros@gm .] def add_person(name, count=1) # I assume adding once as a default is
| 265398 [coreyhaines@] Thanks for the tips, Stefan. I like your tip on doing .dup, as well.
+ 265454 [mlanza@co ca] count.times {@bucket << name }

Download Calvin+Hobbes Script
265330 [curi@cu i. s] The top link on del.icio.us is a site with all the Calvin + Hobbes
+ 265343 [james.britt@] No, first consider the people hosting the content you're snarfing.
| 265346 [curi@cu i. s] It's a good thing I posted. I will remember to put a sleep next time.
| 265349 [curi@cu i. s] Oh. How much sleep is best? One second per image would add an hour to
| 265354 [james.britt@] 60*60*24 might work.
| 265360 [jnj@th co pe] I'm no expert, but it seems to me that Mr. Britt makes a
| 265372 [dangerwillro] A. They're probably hosting Calvin & Hobbes strips illegally, so they
| + 265373 [phlip2005@gm] The ultimate punchline: Calvin has just destroyed Susie D's snowman, and
| + 265375 [ben@bl yt in] They certainly are, and I know from past experience (supporting a site
+ 265382 [jaimeiniesta] it, sure it is an interesting script. I thought about doing a simpler

Re: launchy 0.2.1 Released
265331 [transfire@gm] On Aug 18, 12:12 pm, Jeremy Hinegardner <jer...@hinegardner.org>
265442 [jeremy@hi eg] Yes, probably in hindsight a bad name.  Naming things appropriately is one

Ruby's equivalent to Java's "interface"
265337 [steve@tr pp ] Please forgive this rather naive question, but it's a query that's
265341 [dvohra09@ya ] ...
+ 265364 [o.renaud@la ] I disagree : the equivalent of java's interface is implicit interface. That
| 265369 [kbloom@gm il] You get two differences when you do this: one is that
+ 265370 [dkarapetyan@] ...
  265474 [shortcutter@] You can only define constants in a Java interface, no methods.  A Ruby
  265487 [mikkel@he en] I second that...

Printing variable names
265345 [bulliver@ba ] foo = [s0, s1, s2, s3, s4, s5, s6, s7]
265347 [h4z3@th -c r] Wouldn't it be more logical to use a hash?
265348 [bulliver@ba ] Perhaps, but the order of the variables is significant. I was thinking I might
265351 [bulliver@ba ] @registers = [:zero, :at, :v0, :v1, :a0, :a1, :a2, :a3,

splitting Array - DRY
265376 [josselin@wa ] I am presently splitting an array on 4 successives periods of time , is
265377 [apeiros@gm .] class ClassOfAd
265468 [josselin@wa ] thanks Stefan, I realize that, too frequently, I am programming Ruby as
+ 265470 [shortcutter@] Basically you need a more generalized version of partition. Maybe
| 265753 [josselin@wa ] Thanks Robert... I'll put it in my Personal Ruby Cookbook, that's DRYissimo !
+ 265471 [significants] the Ruby Cookbook (ISBN: 0-596-52369-6) is really great, as it's
  265785 [kaldrenon@gm] I have this book too, and I haven't really delved into it, but I can

Symbol as array index error
265378 [nick314@gm i] ...
265380 [robert.dober] It would be helpfull to tell us where in the code the error occurred.
265393 [nick314@gm i] This is the error message.
265540 [nick314@gm i] This is the error message.

Detecting duplicates in an array, anything in the standard library ?
265381 [thibaut.barr] Just wondering if there is something simple already built in the std
+ 265392 [ari@ar br wn] Couldn't you also just do a union with itself?
| 265394 [dblack@ru yp] ...
| 265395 [ari@ar br wn] The only reason I'll accept that
+ 265415 [w_a_x_man@ya] Here's a modification of a technique used by
| + 265416 [thibaut.barr] Thanks for all your replies!
| + 265418 [transfire@gm] Does everyone agree that #dups is the best name for this? I recently
|   265422 [w_a_x_man@ya] +1
+ 265432 [shortcutter@] Actually you are not deleting duplicates as far as I can see.  Here's
| 265431 [shortcutter@] Did I say it's too late?  Man, I should've worn my glasses...
| 265493 [thomas.mackl] or...
| + 265503 [shortcutter@] It does, but as far as I can see OP wanted exactly the duplicates back.
| | 265521 [gabe@dr gf y] I'm a n00b, sorry if I'm poking nose in. Couldn't the op do something
| | 265524 [dblack@ru yp] [1,2,3,2,4,5,5,6]   => [2,5]
| + 265525 [gabe@dr gf y] [1,2,2,3].uniq
+ 265594 [botp@de mo t] #     inject({}) {|h,v| h[v]=h[v].to_i+1; h}.reject{|k,v| v==1}.keys

Re: Detecting duplicates in an array, anything in the standa
265385 [ed.odanow@wo] No! :-)) - I tried it only using Arrays...
265387 [dblack@ru yp] ...
265389 [ed.odanow@wo] The problem is, that he wants all non unique elements. Unfortunately the
265390 [dblack@ru yp] ...

Getting MySQL column comment metadata?
265397 [mlanza@co ca] How do I go about getting the "Comments" metadata--the one I type via
+ 265399 [mikeisgreat@] I'm not sure what you are asking, so I will take a guess...
+ 265405 [kbloom@gm il] This doesn't appear to be implemented directily in MySQL's C API.
  265438 [mlanza@co ca] Thanks for the help.  This is useful but I would like to use a library
  265453 [mlanza@co ca] The column I was referring to appears in the attached screenshot.  Far

Kevin Howe?
265400 [transfire@gm] Last call for Kevin Howe. Hello?
265410 [ari@ar br wn] You ping...
265411 [transfire@gm] LOL :-)
265439 [robert.dober] The man is lost in outer space and you are laughing????

Re: how to read a ruby symbol from C ?
265404 [yvon.thorava] rb_id2name( SYM2ID( a key T_SYMBOL from a RHASH ))
265443 [nobu@ru y- a] That portion you mentioned is correct.  So something is wrong
265485 [yvon.thorava] OK, i'll look again at that...

Float addition problem / Processor bug?
265406 [dinkel@pi pr] === START ===
+ 265408 [shortcutter@] The second one.  This is a standard rounding issue.  The short
| 265412 [dinkel@pi pr] I kind of knew it ;-) - but still thank you Robert for confirming!
| 265414 [apeiros@gm .] That's no "ruby" problem. You have to understand what floats are (and
| 265419 [dinkel@pi pr] I know that this is no Ruby-specific problem and I can live with it in a
| 265425 [apeiros@gm .] If you have an idea on how to do that, I'm sure the core developers
| 265434 [znmeb@ce ma ] 1. As far as the "principle of least surprise" is concerned, the fact
+ 265413 [matt@ti bi s] <http://docs.sun.com/source/806-3568/ncg_goldberg.html>

'Rite'
265417 [transfire@gm] So has the name 'Rite' for Ruby 2.0 officially gone the way of the
+ 265424 [gmurray@cl u] be wary, the Dodo comes!
+ 265465 [matz@ru y- a] Rite is a code name for my _next_ implementation.  Since YARV came in,
+ 265466 [martindemell] There's always webrite

Converting %2F back to /
265420 [dipesh_bathe] I have a string which contains url. The forward slash in it represented
265423 [dougal.s@gm ] def url_decode(s)
265428 [shortcutter@] irb(main):001:0> require 'uri'
265430 [dougal.s@gm ] It had to be there somewhere, thanks for pointing it out! :o)

Video playback library?
265421 [johnreiter@g] I've recently begun learning ruby (coming from a mainly java world), and
+ 265426 [dangerwillro] VLC is a nice cross-platform app, open source, made in C.
| 265433 [ruby-lang@da] And can be remotely controlled programmaticly via its telnet
| 265456 [johnreiter@g] That might be something worth looking into.  Thanks!
| 265464 [dangerwillro] VLC (videolan.org) is very cool, quite good.
+ 265427 [phlipcpp@ya ] Just a guess; the format of the future is a video rendered as a Flash
  + 265429 [dangerwillro] Yep. You could have bindings/API of some sort like the way RMAgick
  + 265455 [johnreiter@g] Unfortunately, Flash isn't going to be an option for this particular

Library for investigating database schemas?
265437 [mlanza@co ca] I'm wondering what libraries are available for accessing the most
+ 265452 [mlanza@co ca] I think I've uncovered some ways to do this.  If there's a better way,
+ 265887 [no@sp m. le ] As you found, ActiveRecord already fetches column names. The extra

Unmarshal object with PHP
265440 [drogus@gm il] Is there any implamentation of something like Marshal.dump in PHP? Or
+ 265441 [peter@pe er ] ...
+ 265451 [drbrain@se m] Poor workers blame their tools. Good workers build better tools. The
| 265494 [drogus@gm il] Thanks for replies :)
| 265545 [drbrain@se m] That's probably optimal.  Porting Ruby's marshal format to PHP is
+ 265467 [shortcutter@] Kind regards

[ANN] RubyConf 2007: proposal deadline extended
265445 [dblack@ru yp] We've extended the deadline for presentation proposals for RubyConf
265446 [dblack@ru yp] RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242)

MS VC++ Toolkit 2003?
265447 [TimHunter@nc] I've just purchased a new Intel-based iMac and installed Windows XP
265461 [djberg96@gm ] VC++ 8 should work fine. I've built Ruby successfully with it. The only
265463 [halostatue@g] There are some tricks others (Nobu or NaHi, IIRC) have suggested to
265580 [TimHunter@nc] Well, now I confess to being a  bit confused. Just how do I make a new
265644 [halostatue@g] For that, you need either (a) Visual Studio 6 or (b) mingw. There are

how can I open a local file?
265448 [wzfg@si gt l] how can I get the path of a local file, so that I can open and read the
265458 [bulliver@ba ] I guess you may want to browse the CGI docs. [0], [1]. If that doesn't help

Show defining file for methods?
265449 [mlanza@co ca] I don't think this is built in, but maybe I'm wrong.  I was wondering
265504 [ruby@an hr p] With a certain amount of work and hooking of Module::method_added,
265533 [mlanza@co ca] When I have a little more time I'll look into doing what you suggest.

Ruby on the iPhone
265457 [sleight42@gm] Anyone else out there realized that Ruby has been compiled for and now
+ 265459 [drbrain@se m] Nearly this same message was posted two weeks ago.
| 265483 [sleight42@gm] Sorry for the repost then.
+ 265460 [eastmedianyc] ...

ZenTest autotest problem on Windows XP
265480 [nicolas.rimb] I have a problem using autotest on Windows XP. When launching
+ 265621 [AEtzold@gm .] Dear Nicolas,
+ 265709 [jan.svitok@g] I don't think it's a good idea to install ruby in a directory with
+ 265712 [gthiesfeld@g] Try this in your .autotest file
  265713 [gthiesfeld@g] Sorry, I hit send before I was done.  Just wrapping the ruby method in

Current rubygems require idiom
265488 [Bil.Kleb@NA ] I currently have,
+ 265489 [transfire@gm] $ export RUBYOPT=rubygems
| 265491 [Bil.Kleb@NA ] This is for an executable packaged in a gem, i.e.,
| 265516 [halostatue@g] If that's the case, don't bother doing anything special. Just require
+ 265492 [djberg96@gm ] In environments where I have multiple Ruby installations, where some use
| 265508 [dan-ml@da 42] Er, that can't possibly work since LoadError isn't a subclass of
| 265517 [djberg96@gm ] Yeah, yeah, it should have been "rescue LoadError nil".
| + 265522 [dblack@ru yp] I don't think the error specification thing works with the one-line
| + 265523 [tim.pease@gm] I've found this little snippet to be useful for loading other people's gems ...
+ 265515 [ben@bl yt in] begin
| 265526 [apeiros@gm .] Why not just a corrected version of an earlier statement?
| 265534 [ben@bl yt in] Two reasons: first, my option only requires rubygems if it is necessary
+ 265536 [ara.t.howard] i personally use
| 265553 [drbrain@se m] No need to comment anything out, just use ruby -I to override
+ 265556 [drbrain@se m] This is correct and will work.

Ruby performance degraded on custom kernel
265495 [henke@ma .s ] I have a rather odd question regarding ruby's performance on a system
265500 [znmeb@ce ma ] Well ... I'm not sure off the top of my head what it could be, but if
265511 [henke@ma .s ] Thanks for your response.

regex not gsubbing for me.
265498 [pbailey@bn .] Can someone please explain to me why this simple regex substitution
+ 265499 [alex@bl ck e] It works for me...
+ 265501 [apeiros@gm .] Your operation changes the string object in memory. Not the file. You
| 265502 [pbailey@bn .] Thanks. Yeh, I'm doing that actually. Obviously, this is just a snipped
+ 265505 [shortcutter@] Not sure whether that may be related but I'd use (.*?) instead of
  265506 [pbailey@bn .] Robert-
  265541 [overlord@gm ] Take a look at REXML, it parses XML way better than regular expressions.
  265542 [pbailey@bn .] Thanks, Simon. Yes, I see that it's actually part of Ruby out of the
threads.html
top