From: sera@... (Francis Hwang) Date: 2004-02-09T06:56:07+09:00 Subject: Re: two questions Hi Caligari, > First: how can i use a variable name within a regex? In other words, i > explain it with some perl code: Basically, you can treat the regex source like a normal string. Like so: irb(main):001:0> str = "supercali" => "supercali" irb(main):002:0> sub = 'erca' => "erca" irb(main):003:0> str =~ /#{ sub }/ => 3 (BTW, irb is a good quick way to test out a lot of these little questions. Many times you'll be surprised by how Ruby just plain works the way you think it should!) > Second: this is a question on the object orientation consistency of ruby > (i'm not doubt that ruby is consistent, but i'm only a newbie that > search for answers...). > If i declare an instance variale as attr_accessor, i can avoid to write > getter/setter methods, but how can i surely give a value to a variable > without writing the relative method?? Unfortunately, I don't believe there's any way to get around the fact that you'll need some sort of validation or processing after the minutes value is set. For what it's worth, you could use attr_reader to auto-create the reader and then write the setter by hand. Francis