303151-346817 subjects 303578-333219

How can a code block access an object's variables?
303365 [l33tb0y@gm i] Dear Rubyists,
+ 303372 [jj@tr ve iq ] ...
+ 303383 [rick.denatal] class FileReader
  303411 [shortcutter@] No, the complete expression will skip empty lines as well we lines that
  + 303532 [l33tb0y@gm i] You are correct.  I was wrong with that regular expression.  I was
  + 303550 [rick.denatal] Right you are, for some reason I failed to see the square brackets.

Constants in modules
303374 [lcrespom@gm ] I need to do something like this (this is a simplified version of some
303375 [jj@tr ve iq ] ...
303389 [lcrespom@gm ] Yes, it works!!
303416 [davebass@mu ] Yes, this is a common gotcha.

File.open auto-close
303379 [slarbi@gm il] ...
+ 303380 [radek.bulat@] Tm8sIGZpbGUgd29uJ3QgYmUgY2xvc2VkICh5b3UgZGlkbid0IHBhc3MgYmxvY2spIGFuZCB5b3Ug
| 303388 [slarbi@gm il] ...
+ 303382 [jj@tr ve iq ] It's even easier :) Try

Mysterious behavior with loops
303381 [ericlin852@g] a = [1,2,3]
303384 [stefano.croc] Iterating on an array while deleting elements from it is usually a bad idea,
303397 [ericlin852@g] Thanks Stefano, that definitely answered my question.  It's quite

ShellExecute and Win32OLE callback
303390 [rrallan@gm i] I'm trying to add a callback to a ShellExecute call. (Or at least get
303418 [s.korteling@] You need ShellExecuteEx (see
303423 [rrallan@gm i] Thanks Siep;

Ruby .read image upside down?
303394 [contact@pr g] I'm discorvering a strange issue when reading in an image being sent by
303395 [contact@pr g] Ruby .read image upside down?
303406 [leslieviljoe] Can you save the data back from the database in a file and then look at a
304872 [contact@pr g] Still no luck.  I've looked at the .read function and dumped its

$: from C or from ruby
303396 [andre.nho@gm] I'm inspecting the value of $: (the 'require' path) under windows. If

Gems not working
303398 [jimh@av ta -] I am currently not able to install any gems. I was using Gem 1.1.1 but
+ 303407 [leslieviljoe] Have you tried a couple of times? The errors just look like a slow
| 303522 [jimh@av ta -] That's what I thought, but other win32 machines on the same subnet work
| 303525 [hassan.schro] Are you running IPV6 on this system? If so, I'd try disabling that -- no
+ 303628 [tom@in oe he] Hm, that "yaml" file is 20 MB now... is your client timing out, or maybe
  303654 [ttmrichter@g] The gem servers at rubyforge and whoever hosts for ruby on rails seem to
  + 303656 [ttmrichter@g] Since I've had to reinstall all my gems after the upgrade to 1.8.7,
  | + 303673 [tom@in oe he] sudo gem install actionmailer RedCloth [... etc ...]
  | | 303688 [ttmrichter@g] The problem with this is that if -- scratch that, when -- it fails, I
  | | 303689 [tom@in oe he] Ah right, because the gem client is timing out, gotcha.
  | | 303707 [ttmrichter@g] There's a lot that surprises me in the recent gem releases (1.0+).  The
  | | 303741 [tom@in oe he] Yours,
  | | 303748 [ttmrichter@g] Thanks, Tom.  Lack of sleep made me not even think about looking at
  | | 303790 [leslieviljoe] Sorry to repost this, but it should probably have been attached to
  | + 304040 [drbrain@se m] No, there is no problem with the rubyforge mirrors.
  |   314857 [spam@ch vy c] appears to be a 403 if i go directly to
  + 304039 [drbrain@se m] I do not have this problem, and my usage of RubyGems with remote

start_command SCP did not finish successfully (1) (Net::SC
303400 [hellolinus@g] require 'net/scp'

instance method adding another instance method to the class
303401 [neeraj.jsr@g] class Person
303417 [davebass@mu ] It's not necessary to instantiate Person; changing the last line to
303427 [rick.denatal] It's because a nested def doesn't define a method in the class of the

Ruby-Processing library
303402 [sandipfloyd@] I am using the ruby-processing library made available on the GitHub

Re: start_command SCP did not finish successfully -> sftp
303414 [hellolinus@g] I have found on Infoq some exampel code to do the upload iwth sftp.

Quickie: Monkey patching Array
303420 [leon@ti -o l] A quick question: is it possible to monkey patch the Array [] method in
+ 303422 [aredridel@nb] Try [], not []=. They're different methods.
+ 303425 [mikael@ho lu] You monkey patched the []=3D method, not the [] method. Try
| 303428 [leon@ti -o l] I know it's bad behaviour :) But I'm just fiddling with ruby.
| + 303429 [mikael@ho lu] That's an array literal, not Array#[]. No way to overload that, I'm =20
| + 303430 [s.korteling@] try
|   + 303435 [reidmix@ya o] ...
|   + 303464 [leon@ti -o l] Hee Siep,
|     303466 [leon@ti -o l] Ah, I read the post about the array literal.
+ 303426 [s.korteling@] You redefined the []= method, not the [] method.

PHP to Ruby (associative array to Hash)
303421 [s.d@co ca t.] ...
+ 303431 [jan.svitok@g] -  types = { 'aac'   => 'audio/x-aac',
+ 303432 [towb@gm .n t] Only FalseClass and NilClass are false in Ruby, so if it can be an empty
+ 303479 [Joerg.Mittag] This is my take. I shuffled things around a bit, e.g. using constants
  303545 [s.d@co ca t.] ...
  + 303557 [caduceass@gm] * is not pointer notation here.  One way to think about it is that it
  + 303558 [jan.svitok@g] * is not a pointer, it is so-called splat operator (google: ruby

How do i replace actual value in the query with variables?
303434 [aumart@gm il] I try to set up a loop to put the data in the array into the oracle
+ 303436 [caduceass@gm] You can expand within double quotes using "#{my_var}", so maybe
| 303458 [kubo@ji ba .] conn.exec( "UPDATE SCH_EVENT SET P_ID = 2444334 where RANK = :1 AND
| 303548 [caduceass@gm] How can you not still do insecure injection with this?
| 303699 [ninja@sl ph ] Well, if you use single quotes for your SQL string, you can't because either
+ 303498 [andreas.warb] for q in 0..4

Newbie question: Value from YML file into a class...
303437 [mcpierce@gm ] On my project we're using ActiveLdap. One of our classes, called Account. It
303442 [ara.t.howard] probably the yaml keys are strings and you are accessing them via

This Week in Ruby (May 29, 2008)
303440 [acangiano@gm] Cheers,

Newby Question: Check image size before getting with Net::Http
303445 [ruchira.bomi] Dear Expert,
303447 [phasis@gm il] require 'net/http'
303517 [ruchira.bomi] Thank you very much Park.

Find files
303446 [clement.ow@a] using the Find module and search for files and at the same time have
+ 303463 [jgabrielygal] Sorry, I don't have more time to look deeper into this, but with
+ 303468 [botpena@gm i] where does this $d1 come from?
| 303717 [clement.ow@a] It is a date object in the format of MM-YY, in which this object is used
| 303724 [shortcutter@] <snip/>
+ 303503 [shortcutter@] #!/bin/env ruby
  303505 [shortcutter@] Sorry, hit "send" too early.

[ANN] Gerbil 2.1.0
303455 [ snk@gn .o g] Gerbil

how to generate ascii code?
303460 [martin@an le] Dear all,
+ 303465 [Paul.McArdle] '76'.to_i.chr
+ 303467 [phasis@gm il] irb(main):001:0> require 'cgi'
| + 303547 [davebass@mu ] Actually CGI.escape and CGI.unescape are such short methods that you can
| + 303703 [martin@an le] Dear Park Heesob,
|   303706 [phasis@gm il] Take a look at cgi.rb. It is easy to understand.
|   303712 [martin@an le] Dear Park,
|   303714 [phasis@gm il] Of course you don't need to require cgi.
|   303835 [martin@an le] Dear Park,
|   303836 [martin@an le] I got the ascii code of hexa decimal value using
|   303854 [joec_49@ho m] ...
+ 303521 [Rob@Ag le on] You might consider googling "lexical analysis" because the particular

[OT] 7 Ruby Programming ebook
303462 [damphyr@fr e] Yes it is, but I can't resist the temptation anymore. You can draw a

Address search algorithms
303469 [raasdnil@gm ] ...
+ 303476 [dandiebolt@y] ...
| 303477 [flo@an er gr] Actually, i had such a problem. You problem is
+ 303480 [eleanor@ga e] Assuming these are UK-only addresses, at the very least you should
  303494 [raasdnil@gm ] ...
  303497 [eleanor@ga e] You have my sympathy ;)

split a string at tab positions
303470 [suresh.amrit] I am a newbie to ruby and when i tried to split a string at tab
+ 303471 [botpena@gm i] probably your editor is converting the tab to spaces.
+ 303472 [thehcdreamer] ...
| 303474 [suresh.amrit] Thank you both. It was the double quote issue...when i gave split "\t"
+ 303473 [skraemer@mi ] Regexes take the form /.../ (see http://www.ruby-doc.org/core/classes/Regexp.html)
| 303772 [mo_mail@on h] I think his piece of code also works - in my mind, the problem is the
+ 303771 [mo_mail@on h] The problem is the '\t' - anything inside single quotes is not touched

Using gem to deploy a autoconf packages, expriences?
303478 [florian.ebel] I'm just thinking about how well suited RubyGems might be
303535 [pbrannan@at ] - Specify all the autoconf-generated files to be included in the gem

How do you convert a hexadecimal number to a binary number?
303481 [small.busine] I can't find a clue how to convert a hexadecimal number to a binary
+ 303482 [thehcdreamer] ...
+ 303483 [billk@ct .c ] => "1011111011101111"

defining Private/Protected class attributes
303484 [cmonoxide@gm] If I would like to define some private/protected class attributes, I
+ 303485 [dblack@ru yp] class C
+ 303516 [s.korteling@] class Test
  303586 [cmonoxide@gm] Thanks all!

Proc multiple returns?
303486 [c00lryguy@gm] def foo(&block)
+ 303487 [dblack@ru yp] def foo
| 303489 [dblack@ru yp] foo { break "bar", "baz" }
| 303561 [c00lryguy@gm] Almost. 'break' well...breaks it though, cause im recursively calling
+ 303495 [andreas.warb] irb(main):010:0> def foo(&block); block.call if block; end
  303496 [c00lryguy@gm] You dont understand, I'm making a simple HTML module for easy document
  + 303499 [andreas.warb] Andreas
  | 303501 [c00lryguy@gm] Yeah I know, I've looked at this before i started makin this. I'm really
  + 303500 [AEtzold@gm .] Dear Ryan,
  | 303529 [c00lryguy@gm] You cant use the return function within procs.
  | 303565 [ara.t.howard] but
  | 303568 [c00lryguy@gm] Beautiful, thanks alot man!
  + 303564 [ara.t.howard] require 'rubygems'

Re: How do you convert a hexadecimal number to a binary numb
303488 [c00lryguy@gm] From http://www.tek-tips.com/viewthread.cfm?qid=1026407&page=1
303490 [small.busine] Big thanks for the quick reply, Ryan!
303491 [c00lryguy@gm] NP, I just happened to needed this same info like two days ago

Ruby 1.9 migration problem on Windows
303492 [andreas.warb] I have an application, which currently runs under ruby 1.8.6. I want to

not a valid win32 application?? help, please
303493 [dark_sgtphoe] I don't understand why my computer won't run any of my Ruby programs
+ 303526 [damnbigman@g] ...
+ 303538 [davebass@mu ] Operating system and exact error message?

in the callback why I must use self
303507 [neeraj.jsr@g] class User < ActiveRecord::Base
303513 [jameskilton@] The issue here is that the parser can't tell the difference between
303524 [Rob@Ag le on] ...and the reason Ruby can't has to do with the dynamic way that

Re: How do i replace actual value in the query with variable
303514 [c00lryguy@gm] (0..4).each { |q| conn.exec( 'UPDATE SCH_EVENT SET P_ID = 2444334 where
303543 [cmdjackryan@] Gotta love an SQL injection waiting to happen..
+ 303560 [caduceass@gm] Umm... duh.  It was probably an example.  Anybody worth their grain of
+ 303567 [flo@an er gr] Converting to a number type before using the value is injection safe.
  303570 [aumart@gm il] Yeah.. this is just a example.....

getting standard error and output from ruby script in real time
303519 [stefano.croc] I'm trying to write an editor for ruby in ruby using the KDE4 bindings for
+ 303536 [davebass@mu ] It's to do with buffering. Buffering takes place within Ruby (I think)
| 303596 [stefano.croc] Thanks for the information. I think I'll look at the source code of some tool
| 303597 [Rob@Ag le on] $stdout.sync = true; $stdout.flush
| 303607 [stefano.croc] I don't think that would work. If I understand correctly what you mean, that
| + 303616 [Rob@Ag le on] If you have no need to maintain separate streams do the equivalent of =20=
| + 303626 [ara.t.howard] what you want to do is easily accomplished using session.rb
|   303642 [stefano.croc] Thanks for telling me about session. Unfortunately, it still doesn't work. I
+ 303566 [xcampanoli@g] STDERR.puts
  303595 [stefano.croc] I know that puts writes on standard output, this is what I want it to do. It's

Eclipse RDT plugin
303527 [tahura@ho ma] I'm fixing a bug on an existing Ruby application. Everything I know
303600 [netcam@gm il] Use the eclipse dynamic lang toolkit for ruby DLTK and just configure

parsing a URI's base authority
303531 [a.flow@ti ca] I am looking for a ruby library to reliably determine the base

full path require
303533 [aidy.lewis@g] Is it possible to find out the full path of all the files that have
+ 303539 [ara.t.howard] oops - ignore that other post, i meant
+ 303540 [ara.t.howard] puts $:.map{|path| File.expand_path path}

ruby gem to do https connection
303537 [junkone1@gm ] is there a ruby gem that can do a https connection to the following

Problem of trying to get gmail atom feed in ruby
303549 [carfield@gm ] http = Net::HTTP::new('mail.google.com', 443);

IDE Supporting Global Class List (Yes I searched)
303554 [humanx2000@h] Before I post this, I did search this site + google for the answer. I
303555 [huw@da kn on] Can you explain what you mean by a Global Project Class view. I am one
303556 [humanx2000@h] PHPED http://www.nusphere.com/products/phped_52/large_image1.htm
303563 [huw@da kn on] We have RDoc documentation in tooltips or in a docked window. We have

gdata-ruby and all other Google Data Api'S
303559 [dsisnero@gm ] ...

The Gems Repository Stats
303562 [leslieviljoe] Wondering why the endless "bulk updating" takes so long I looked that
304034 [drbrain@se m] You are looking at RubyGems 0.9.4 or older, so this code is at least
304051 [leslieviljoe] Probably my regular expressions letting me down, I thought this was
304060 [drbrain@se m] Yes, 2-4 weeks out.  I have to go through the rest of the tracker

Unbuffered output with Logger (newbie question)
303569 [ericlin852@g] I'm trying to use Ruby's built-in Logger facility, and I'm not able to
303592 [davebass@mu ] File is a subclass of IO, and IO has a flush method, which File
303605 [shortcutter@] There is a much better option: create the File with File::SYNC.  You
303687 [ericlin852@g] It appears File::SYNC doesn't exist (at least not in my copy of

splitting help needed
303571 [dark_sgtphoe] I have a program that someone on this forum helped me fix before that
+ 303573 [s.korteling@] The method split splits up a string and it will put the parts in an
| + 303575 [dark_sgtphoe] Well, it isn't writing a new file for each line... but, it's not listing
| | 303579 [dblack@ru yp] It's writing a new file for each element in the input. You're writing
| | 303584 [dark_sgtphoe] Ohhh, I see... thank you so much! :-D
| | 303585 [tristin.colb] ...
| + 303581 [bbxx789_05ss] str = "hello world goodbye"
| | + 303590 [dblack@ru yp] My benchmarks suggest that it's a little faster (about 10%).
| | | 303619 [bbxx789_05ss] I did--8 years ago.
| | | 303620 [bbxx789_05ss] user     system      total        real
| | + 303593 [davebass@mu ] Larry Wall (Perl supremo) has called this sort of thing LTS: leaning
| |   303594 [dblack@ru yp] I always figured it's easiest just to learn the regex stuff and get it
| |   303598 [rick.denatal] Some of the features Ruby 'stole' from Perl are things I use fairly
| |   + 303608 [shortcutter@] That's true.  I usually try to compact code in order to increase
| |   | 303618 [dblack@ru yp] I do think that one of the great things about Ruby is that, to a
| |   | 303644 [shortcutter@] Absolutely agree.
| |   + 303617 [dblack@ru yp] I like code golf, as long as it's clear that it's code golf -- that
| + 303591 [dblack@ru yp] Actually without an argument it will split on any amount of
+ 303574 [s.korteling@] Oh. Well, you will end up with the cities New, York, Chicago, Boston.

[QUIZ] Price Ranges (#164)
303576 [matthew.moss] ...
+ 303725 [andrea.fazzi] Bye.
+ 303726 [       x@y. ] ...
+ 303786 [steverhahn@h] ...
+ 303824 [jgabrielygal] Here's my solution. I use codeforpeople's main, so the program accepts
+ 303847 [list.push@gm] =begin
+ 303867 [steverhahn@h] ...
+ 304179 [d.phillipsds] Here's my quick attempt
  304181 [d.phillipsds] Sorry for the double post.