[#177639] memoize to a file — Brian Buckley <briankbuckley@...>

Hello all,

14 messages 2006/02/01

[#177686] ANN: WSS4R was released — "Roland Schmitt" <Roland.Schmitt@...>

Hi everyone,

21 messages 2006/02/01

[#177712] Seeking Continuations Links — James Edward Gray II <james@...>

Myself and a few others are trying to get together a "Playing Around

12 messages 2006/02/01

[#177715] Indentation vs. "end"s — "Rubyist" <nuby.ruby.programmer@...>

Hi,

82 messages 2006/02/01
[#177722] Re: Indentation vs. "end"s — doug00@... 2006/02/01

Yes I really like the end statements, and they make it easier for

[#177943] Re: Indentation vs. "end"s — Hal Fulton <hal9000@...> 2006/02/02

doug00@gmail.com wrote:

[#178227] Re: Indentation vs. "end"s — Michal Suchanek <hramrach@...> 2006/02/03

On 2/2/06, Hal Fulton <hal9000@hypermetrics.com> wrote:> doug00@gmail.com wrote:> > Yes I really like the end statements, and they make it easier for> > beginners. It's possible to support both indenting and end statements> > (i.e. support one mode or the other), and you don't need python's> > redundant and unnecessary colons. I implemented this myself in a> > parser. I don't think it is appropriate for ruby, however.> >> > What would be even better would be to allow optional labels after end> > statements, such as "end class", "end def", so the parser can catch> > more errors.> > I've implemented this as well in a separate project.> >>> Not a bad idea in itself. In fact, I think that really old Ruby> versions (prior to my learning it with 1.4) did something like> that. When modifiers were introduced (x if y, x while y, etc.)> parsing became difficult and they were dropped. I think that's> the case.

[#178134] Re: Indentation vs. "end"s — Yukihiro Matsumoto <matz@...> 2006/02/03

Hi,

[#178139] Re: Indentation vs. "end"s — Cameron McBride <cameron.mcbride@...> 2006/02/03

I'm out of my league, but...

[#177816] neuroimage software - scientific computing and visualization — "Darren L. Weber" <darrenleeweber@...>

20 messages 2006/02/01

[#177902] Job Vacancy RoR — "stephen@..." <stephen@...>

I am part of a small Agency that supplies contractors to clients. A

15 messages 2006/02/01
[#177919] Re: Job Vacancy RoR — tsumeruby@... 2006/02/02

Please use sites like monster or dice if you wish to post jobs. Some have been

[#178072] Job postings? Please! (Was: Re: Job Vacancy RoR) — Eric Hodel <drbrain@...7.net> 2006/02/02

On Feb 1, 2006, at 5:16 PM, tsumeruby@tsumelabs.com wrote:

[#177996] Chomping and stomping — John Maclean <info@...>

Chaps,

17 messages 2006/02/02

[#178218] Splitting the Loot (#65) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

33 messages 2006/02/03

[#178265] Ruby IDEs — Chris <cpmbailey@...>

After years of programming in C++, Java et al my new job used Smalltalk

15 messages 2006/02/03

[#178298] Editor on Mac OS X — "Dan Munk" <danmunk@...>

Hello,

19 messages 2006/02/04

[#178332] Extract hash into local variables? — csn <cool_screen_name90001@...>

Is there a Ruby function similar to PHP's extract/list? What I'd like to

17 messages 2006/02/04

[#178364] Problem with weak references on OS X 10.3 — Caleb Clausen <vikkous@...>

I am having problems with weak references. The program below exhibits

10 messages 2006/02/04

[#178392] Quiz #65, Principle of Great Surprise, and Array.delete sledgehammer — Dave Howell <groups@...>

I thought I was actually going to enter my first RubyQuiz, but I've

25 messages 2006/02/04

[#178393] built-in vs. standard library — Mark Volkmann <r.mark.volkmann@...>

I'm confused about whether the Date class is built-in or in the

11 messages 2006/02/04

[#178416] Scanning a string for decimal numbers — Jeppe Jakobsen <jeppe88@...>

Hi all, how do you scan a string and avoid getting my decimal numbers

23 messages 2006/02/04

[#178579] Ruby jargon and slang — Hal Fulton <hal9000@...>

I'm assembling a list of Ruby community "usages" and I want to make

29 messages 2006/02/06

[#178658] Problems building binaries on OS X 10.4 — "Eric Promislow" <eric.promislow@...>

This is with the Ruby that ships with 10.4 (Tiger). We haven't tried

6 messages 2006/02/06

[#178710] reasons to use else inside rescue — Mark Volkmann <r.mark.volkmann@...>

I understand that the code in the else part of a begin block is only

9 messages 2006/02/07
[#178734] Re: reasons to use else inside rescue — "Robert Klemme" <bob.news@...> 2006/02/07

David Vallner wrote:

[#178752] Re: reasons to use else inside rescue — Mark Volkmann <r.mark.volkmann@...> 2006/02/07

On 2/7/06, Robert Klemme <bob.news@gmx.net> wrote:> David Vallner wrote:> > D Utorok 07 Febru疵 2006 03:33 Mark Volkmann nap﨎al:> >> I understand that the code in the else part of a begin block is only> >> executed if no exceptions are raised by code in the begin block.> >> However, the same is true of code at the end of the begin block. Why> >> not put the code there?> >>> >> For example, I believe these are equivalent.> >>> >> begin> >> do_something> >> rescue> >> handle_exception> >> else> >> do_more_stuff> >> end> >>> >> begin> >> do_something> >> do_more_stuff> >> rescue> >> handle_exception> >> end> >>> >> I suppose a difference is that if "do_more_stuff" raises an> >> exception, the first example can't rescue it and the second might.> >> Is that the only difference?> >>> >> --> >> R. Mark Volkmann> >> Partner, Object Computing, Inc.> >> > There's an else part in a begin / end block?! Oh dear. Heavens> > protect us...>> Why?>> > It seems pretty equivalent to plain old:> >> > begin> > do_something> > rescue> > handle_exception> > end> > do_more_stuff> >> > Do we have a syntax guru to elaborate on this?>> Although not being a syntax guru, the idiom you presented is definitely> *not* equivalent. do_more_stuff will also be called if an exception was> caught and not reraised while code in the "else" branch is only invoked if> there was no exception raised.>> > That said, my wild guess would be that in the code fragment> > (apologies for using different method names):> >> > begin> > foo> > rescue> > bar> > else> > baz> > finally>> "finally" is Java - you probably meant "ensure".>> > quux> > end> >> > (*sic* - messiest code excerpt ever)> >> > if #foo didn't raise an Exception, the order of executions would be> > #foo, #baz, and then #quux. That is, unless the else is nothing more> > than no-op syntactic sugar for just putting the statements after a> > begin / rescue / finally block.>> As Mark said, a *rough* equivalent is to put code in the else part> directly before the first rescue. But they do not have the same> semantics! The difference is that all exceptions raised between "begin"> and "rescue" are potentially subject to exception handling on one of the> "rescue" branches. This is not true for code in the "else" branch.>> Another reason to put code into the else branch is documentation. It's> visibly clear that this code does not belong to the main functionality of> the begin end block but that it's intended to act on successfull execution> of the block.

[#178784] Ruby in Browsers? — petermichaux@...

Hi,

15 messages 2006/02/07
[#178787] Re: Ruby in Browsers? — Gregory Seidman <gsslist+ruby@...> 2006/02/07

On Wed, Feb 08, 2006 at 12:58:26AM +0900, petermichaux@yahoo.com wrote:

[#178808] Start from the start - Ruby or ruby on rails — eain.jones@...

I'm looking to start developing a simple task management application

23 messages 2006/02/07
[#178813] Re: Start from the start - Ruby or ruby on rails — Daniel Nugent <nugend@...> 2006/02/07

I'd say your best bet would be to start with a couple of Ruby

[#178816] Re: Start from the start - Ruby or ruby on rails — Jules Jacobs <devlists-ruby-talk@...> 2006/02/07

I think you meant this one:

[#178854] Re: Start from the start - Ruby or ruby on rails — "Konrad Roziewski" <kroziewski@...> 2006/02/07

I completely agree with Jules: try Rails from the start and learn Ruby

[#178909] Re: Start from the start - Ruby or ruby on rails — eain.jones@... 2006/02/08

Thanks to everybody for the recommendations. I had a lot of the links

[#178965] Re: Start from the start - Ruby or ruby on rails — James Edward Gray II <james@...> 2006/02/08

On Feb 8, 2006, at 3:53 AM, eain.jones@gmail.com wrote:

[#178999] Re: Start from the start - Ruby or ruby on rails — "Seth Thomas Rasmussen" <sethrasmussen@...> 2006/02/08

Hi James,

[#179022] Re: Start from the start - Ruby or ruby on rails — eain.jones@... 2006/02/08

James and Seth,

[#178863] Meta-Meta-Programming — Erik Veenstra <pan@...>

30 messages 2006/02/07

[#178942] boolean annoyance — Claudio Jeker <cjeker@...>

Hello,

28 messages 2006/02/08
[#178949] Re: boolean annoyance — Matthew Moss <matthew.moss.coder@...> 2006/02/08

> there is one thing in ruby that annoys me most (at least for now).

[#179039] Re: boolean annoyance — Claudio Jeker <cjeker@...> 2006/02/08

On Thu, Feb 09, 2006 at 01:16:26AM +0900, Matthew Moss wrote:

[#179063] Re: boolean annoyance — Austin Ziegler <halostatue@...> 2006/02/09

On 08/02/06, Claudio Jeker <cjeker@diehard.n-r-g.com> wrote:

[#179071] Re: boolean annoyance — Claudio Jeker <cjeker@...> 2006/02/09

On Thu, Feb 09, 2006 at 09:15:54AM +0900, Austin Ziegler wrote:

[#180105] Re: boolean annoyance — Austin Ziegler <halostatue@...> 2006/02/16

On 2/8/06, Claudio Jeker <cjeker@diehard.n-r-g.com> wrote:> On Thu, Feb 09, 2006 at 09:15:54AM +0900, Austin Ziegler wrote:> > On 08/02/06, Claudio Jeker <cjeker@diehard.n-r-g.com> wrote:> > >> It's actually the most illogic part of languages like C that treat 0> > >> as false. Believe me, having spent most of my programming life using> > >> C/C++ and being used to that, I make mistakes regularly whilst writing> > >> Ruby code.> > >>> > >> 0 is an integer and quite often a valid value. C's treatment of 0 as> > >> false is convenient in some situations but horribly inconvenient in> > >> others. Because if I'm expecting an integer and zero is a legal> > >> value, then you have to start playing around in your conditionals...> > >> "Okay, today any -1 is false"... or even at different levels than> > >> that. Part of the problem is that C doesn't have an actual NULL...> > >> NULL is just defined as zero. Overlap, explosions, crash and burn...> > > If you are inspecting a integer against nothing end everything is just> > > legal, why are you inspecting it?> >> > Sorry, but that doesn't work. If you have something that returns an> > integer value -- consider strtol(3). This can return *any* valid integer> > value, but if you get a 0, LONG_MAX, or LONG_MIN, you have to *then*> > check errno to see if the conversion was, in fact, successful. (And the> > conversion could be unsuccessful for any number of reasons.)> This is not correct. strtol(3) does not return 0 in case of an error. It> sets errno to ERANGE and returns LONG_MAX or LONG_MIN.

[#178975] Sandboxing eval'd code — eastcoastcoder@...

I'm working on a web app with complicated and ever changing business

19 messages 2006/02/08

[#179035] Geocoder 0.1.0 — Paul Smith <paul@...>

Geocoder is a library for Ruby developers and a command-line utility

13 messages 2006/02/08

[#179121] Ruby on AIX? — Obie Fernandez <obiefernandez@...>

We're looking at big IBM hardware running AIX as a potential

11 messages 2006/02/09

[#179125] Re: Yahoo! Widgets (JavaScript) - do we have a anything like this? — Nuralanur@...

Dear Glenn,

15 messages 2006/02/09
[#179138] Re: Yahoo! Widgets (JavaScript) - do we have a anything like this? — David Vallner <david@...> 2006/02/09

Dňa Štvrtok 09 Február 2006 10:32 Nuralanur@aol.com napísal:

[#179154] Re: Yahoo! Widgets (JavaScript) - do we have a anything like this? — tsumeruby@... 2006/02/09

> I believe Glenn called for something that lets him do desktop applets, not

[#179162] Re: Yahoo! Widgets (JavaScript) - do we have a anything like this? — david@... 2006/02/09

Quoting tsumeruby@tsumelabs.com:

[#179168] Re: Yahoo! Widgets (JavaScript) - do we have a anything like this? — tsumeruby@... 2006/02/09

On Friday 10 February 2006 01:59 am, david@vallner.net wrote:

[#179184] Re: Yahoo! Widgets (JavaScript) - do we have a anything like this? — David Vallner <david@...> 2006/02/09

I had a look at Tile, and it looks promising too. But I tried doing some

[#179216] Re: Yahoo! Widgets (JavaScript) - do we have a anything like this? — tsumeruby@... 2006/02/09

On Friday 10 February 2006 04:54 am, David Vallner wrote:

[#179262] FasterGenerator (#66) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

52 messages 2006/02/10
[#179276] Re: [QUIZ] FasterGenerator (#66) — Matthew Moss <matthew.moss.coder@...> 2006/02/10

Not being familiar with all the various Ruby packages and libs, I

[#179702] Re: [QUIZ] FasterGenerator (#66) — James Edward Gray II <james@...> 2006/02/13

On Feb 10, 2006, at 7:53 AM, Ruby Quiz wrote:

[#179340] why would i want to put my mysql password in the yml file? — trevor <trevor@...>

hello - i'm new!

19 messages 2006/02/11

[#179351] Private methods - only available to oneself? — "minkoo.seo@..." <minkoo.seo@...>

Hi, all.

44 messages 2006/02/11
[#179382] Re: Private methods - only available to oneself? — "Minkoo Seo" <minkoo.seo@...> 2006/02/11

I'm sorry Erik. I'm not native English speaker. So, sometimes it's not

[#179385] Re: Private methods - only available to oneself? — "Erik Veenstra" <google@...> 2006/02/11

> I'm sorry Erik. I'm not native English speaker. So, sometimes

[#179395] Re: Private methods - only available to oneself? — "Phrogz" <gavin@...> 2006/02/11

I think the purpose of instance_eval is one of those "sharp knife"

[#179742] Re: Private methods - only available to oneself? — "Adam P. Jenkins" <thorin@...> 2006/02/13

Phrogz wrote:

[#179366] OpenStruct problem — "Minkoo Seo" <minkoo.seo@...>

OpenStruct class seems to be misbehave when it comes to hashing.

12 messages 2006/02/11

[#179434] Quickly before all is lost! — Alex Combas <alex.combas@...>

ZOMG! Ruby RSS feeds growing exponentially!

15 messages 2006/02/11

[#179447] Rake Friday? — Bil Kleb <Bil.Kleb@...>

Is there a Friday,

23 messages 2006/02/12

[#179503] Cutting a piece of text — Zdebel <szczupienczyk@...>

Helo !

14 messages 2006/02/12

[#179520] Rescuing blocks? — Daniel Nugent <nugend@...>

Hey guys,

26 messages 2006/02/12
[#179523] Re: Rescuing blocks? — David Vallner <david@...> 2006/02/12

Dňa Nedeľa 12 Február 2006 19:26 Daniel Nugent napísal:

[#179524] Re: Rescuing blocks? — Daniel Nugent <nugend@...> 2006/02/12

Whoops, shoulda thought of that, a-doy.

[#179528] Re: Rescuing blocks? — Lou Vanek <vanek@...> 2006/02/12

this works,

[#179531] Re: Rescuing blocks? — Mark Volkmann <r.mark.volkmann@...> 2006/02/12

On 2/12/06, Lou Vanek <vanek@acd.net> wrote:

[#179532] Struct creates non-standard classes — Mark Volkmann <r.mark.volkmann@...>

If Struct is a shorthand way for creating Classes, why don't objects

12 messages 2006/02/12
[#179536] Re: Struct creates non-standard classes — David Vallner <david@...> 2006/02/12

Dňa Nedeľa 12 Február 2006 20:45 Mark Volkmann napísal:

[#179543] Re: Struct creates non-standard classes — Mark Volkmann <r.mark.volkmann@...> 2006/02/12

On 2/12/06, David Vallner <david@vallner.net> wrote:> D Nedeオa 12 Febru疵 2006 20:45 Mark Volkmann nap﨎al:> > If Struct is a shorthand way for creating Classes, why don't objects> > created from those Classes have instance_variables?> >>> My guess is because Struct directly accesses a C hashtable, instead of> registering instance variables in the interpreter. Not like it should matter> unless you for some reason with to access the variables with reflection> instead of the accessors, which I can't imagine why you'd want to do.

[#179554] Re: Struct creates non-standard classes — Robert Klemme <shortcutter@...> 2006/02/12

2006/2/12, Mark Volkmann <r.mark.volkmann@gmail.com>:> On 2/12/06, David Vallner <david@vallner.net> wrote:> > D Nedeオa 12 Febru疵 2006 20:45 Mark Volkmann nap﨎al:> > > If Struct is a shorthand way for creating Classes, why don't objects> > > created from those Classes have instance_variables?

[#179546] Mongrel 0.3.1 -- New Site/Runs Right — Zed Shaw <zedshaw@...>

Hello All,

25 messages 2006/02/12

[#179596] couple quick questions about YARV — Joshua Haberman <joshua@...>

I know YARV is far from finished, but:

11 messages 2006/02/12

[#179623] tree structures — "frank" <mjzanis@...>

Hi,

15 messages 2006/02/13

[#179741] ruby html (or xhtml) forms class... — "Skeets" <skillet3232@...>

does one exist? i use an excellent php based forms class when i code

16 messages 2006/02/13

[#179790] Mongrel 0.3.2 -- The Right Site/All Requests Answered — Zed Shaw <zedshaw@...>

"Another Mongrel release?! Is he insane?" Yeah, basically.

4 messages 2006/02/14
[#179798] Re: [ANN] Mongrel 0.3.2 -- The Right Site/All Requests Answered — Aaron Kulbe <akulbe@...> 2006/02/14

On 2/13/06, Zed Shaw <zedshaw@zedshaw.com> wrote:> "Another Mongrel release?! Is he insane?" Yeah, basically.>> This is yet another release of Mongrel that adds a bunch of little features> people requested and I found were needed. This release is almost entirely> targeted at Ruby on Rails folks as the majority of the changes went into the> mongrel_rails runner.>> Get this release from the (correctly linked) site:>> * http://mongrel.rubyforge.org/ -- project site.> * http://rubyforge.org/frs/?group_id=1306 -- direct to downloads.>>> == What's Mongrel>> Mongrel is a fast HTTP library and server for Ruby that is intended for> hosting Ruby web applications of any kind using plain HTTP rather than> FastCGI or SCGI. It is framework agnostic and already supports Ruby On> Rails, Og+Nitro, and Camping frameworks.>>> == Getting Mongrel>> Simplest way to get Mongrel is through RubyGems. If you've got Ruby On> Rails floating around you just do this:>> $ gem install mongrel (or gem upgrade if you've already got it)> $ cd myrailsapp> $ mongrel_rails start -d>> That runs it in the background in *development* mode on port 3000. Use the> -h option to start to see the various options you have. Stopping it is> just:>> $ mongrel_rails stop>> Win32 people will need to avoid -d until I can test things an get a service> written.>> == Changes>> Lots of little fixes and enhancements that people requested from the last> release.>> * FAQ questions answered on threading and deployment scenarios.> * Added some additional text to make the side icons a little clearer.> * Created a dogs page with some people's favorite pets.> * Write out a better message for 'mongrel_rails start' giving the> environment and other stuff.> * Default to using ENV['RAILS_ENV'] or "default" as environment.> * Removed the restriction on the environments so people can have custom> ones.> * Added options for:> * -n Number of processor threads.> * -t Timeout for each processor before it kills a request.> * -m Specify additional MIME type mappings in YAML format.> * -c Change to directory before starting (both for start and stop> commands)> * -r Use a different document root from "public"> * Use "rb" as open mode on all platforms (for windows binary files)> * Fixed bug in DirHandler which prevented people from altering MIME mapping.>> The big change is the additional options that people have for running Ruby> On Rails applications via Mongrel. Please try them out with your weird> configurations and let me know how they work.>> == Dogs>> Don't forget to check out peoples favorite pets at> http://mongrel.rubyforge.org/dogs.html>> Zed A. Shaw> http://www.zedshaw.com/>>>

[#179860] How to run a Ruby file without installing Ruby? — "Rubyist" <nuby.ruby.programmer@...>

Let's suppose that I wrote a Ruby program which is incredibly

17 messages 2006/02/14

[#179978] gem/rdoc/ri errors on mingw — Alex Combas <alex.combas@...>

Hello,yesterday I switched from the very good, perfectly functionalone-click installer to a build-it-yourself-ruby-compile on winXPwith the mingw environment.

8 messages 2006/02/15

[#180000] Getting Started — lists@...

Hi, I'm trying to get started with Ruby, but I don't feel that any of

14 messages 2006/02/15

[#180012] Possible Ruby-centric NASA SBIR area — Bil Kleb <Bil.Kleb@...>

I've been asked to write a small topic area

20 messages 2006/02/15

[#180021] Ruby script to Module/Class refactor — "James B. Byrne" <ByrneJB@...>

I have written my first live ruby script that actually performs useful

14 messages 2006/02/15

[#180046] OT: Is this worth a try? — "gregarican" <greg.kujawa@...>

I am trying out some other scripting languages and wanted to give

26 messages 2006/02/15
[#180063] Re: OT: Is this worth a try? — David Vallner <david@...> 2006/02/15

Dňa Streda 15 Február 2006 20:33 gregarican napísal:

[#180080] Eating CPAN - Was Port A Library. — John Carter <john.carter@...>

CPAN has 9502 modules.

13 messages 2006/02/16

[#180202] recontextualizing a block (looking for deep magic) — ptkwt@... (Phil Tomson)

What I'm trying to do probably isn't possible, but maybe someone knows some

18 messages 2006/02/16

[#180204] Rubuntu LiveCD I need vim/emacs configs! — Ezra Zygmuntowicz <ezmobius@...>

Friends-

32 messages 2006/02/16
[#182082] Re: Rubuntu LiveCD I need vim/emacs configs! — "Joe" <joesavona@...> 2006/03/01

Just a thought - what about creating a VMware player appliance with all

[#185813] Re: Rubuntu LiveCD I need vim/emacs configs! — "Brandon Hines" <brandonhines@...> 2006/03/25

This topic has been dead for a few days...how's the project coming?

[#185901] Re: Rubuntu LiveCD I need vim/emacs configs! — "ezmobius mob" <ezmobius@...> 2006/03/25

On 3/24/06, Brandon Hines <brandonhines@gmail.com> wrote:

[#180213] Don't let this happen to Ruby, pleeeeease? — Glenn Smith <glenn.ruby@...>

This is quite a good article I just read via a link on artima (I think).

26 messages 2006/02/16
[#180216] Re: Don't let this happen to Ruby, pleeeeease? — James Britt <james_b@...> 2006/02/16

Glenn Smith wrote:

[#180471] Re: Don't let this happen to Ruby, pleeeeease? — "Glenn Smith" <glenn.ruby@...> 2006/02/18

Sorry, posted my rant, then disappeared for two days!

[#180556] Re: Don't let this happen to Ruby, pleeeeease? — David Vallner <david@...> 2006/02/19

Dňa Sobota 18 Február 2006 21:48 Glenn Smith napísal:

[#180566] Re: Don't let this happen to Ruby, pleeeeease? — "Glenn Smith" <glenn.ruby@...> 2006/02/19

SWYgSSByZXByZXNlbnQgaGFsZiBvZiBSdWJ5J3MgdXNlcnMgKG90aGVyIFdpbmRvd3MgdXNlcnMg

[#180280] metakoans.rb (#67) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

80 messages 2006/02/17
[#180334] Re: [QUIZ] metakoans.rb (#67) — "Patrick Hurley" <phurley@...> 2006/02/17

On 2/17/06, Ruby Quiz <james@grayproductions.net> wrote:

[#180335] Re: [QUIZ] metakoans.rb (#67) — ara.t.howard@... 2006/02/17

On Sat, 18 Feb 2006, Patrick Hurley wrote:

[#180337] Re: [QUIZ] metakoans.rb (#67) — "Patrick Hurley" <phurley@...> 2006/02/17

On 2/17/06, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:

[#180338] Re: [QUIZ] metakoans.rb (#67) — ara.t.howard@... 2006/02/17

On Sat, 18 Feb 2006, Patrick Hurley wrote:

[#180341] Re: [QUIZ] metakoans.rb (#67) — "Wilson Bilkovich" <wilsonb@...> 2006/02/18

On 2/17/06, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:

[#180345] Re: [QUIZ] metakoans.rb (#67) — "Jacob Fugal" <lukfugl@...> 2006/02/18

On 2/17/06, Wilson Bilkovich <wilsonb@gmail.com> wrote:

[#180346] Re: [QUIZ] metakoans.rb (#67) — "Wilson Bilkovich" <wilsonb@...> 2006/02/18

On 2/17/06, Jacob Fugal <lukfugl@gmail.com> wrote:

[#180352] Re: [QUIZ] metakoans.rb (#67) — ara.t.howard@... 2006/02/18

On Sat, 18 Feb 2006, Wilson Bilkovich wrote:

[#180355] Re: [QUIZ] metakoans.rb (#67) — "Wilson Bilkovich" <wilsonb@...> 2006/02/18

On 2/17/06, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:

[#180393] Re: [QUIZ] metakoans.rb (#67) — Sylvain Joyeux <sylvain.joyeux@...> 2006/02/18

I'm at 13

[#180404] Re: [QUIZ] metakoans.rb (#67) — "Patrick Hurley" <phurley@...> 2006/02/18

I also have 13; however, two lines exceed 80 columns. Additionally, I

[#180284] Re: Python for Fortran Programmers — Stephan Mueller <d454d@...>

* Bil Kleb <Bil.Kleb@NASA.gov> [060217 11:32]:

13 messages 2006/02/17
[#180285] Re: Python for Fortran Programmers — ara.t.howard@... 2006/02/17

On Sat, 18 Feb 2006, Stephan Mueller wrote:

[#180358] Ruby scripts as Win32-Service — "William Ramirez" <mercan01@...>

I've through together a ruby script as test for a monitoring app for a few

10 messages 2006/02/18
[#180360] Re: Ruby scripts as Win32-Service — "Patrick Hurley" <phurley@...> 2006/02/18

On 2/17/06, William Ramirez <mercan01@gmail.com> wrote:

[#180362] Desktop apps written in Ruby? — petermichaux@...

Hi,

18 messages 2006/02/18
[#180365] Re: Desktop apps written in Ruby? — "Wilson Bilkovich" <wilsonb@...> 2006/02/18

On 2/17/06, petermichaux@yahoo.com <petermichaux@yahoo.com> wrote:

[#180370] Re: Desktop apps written in Ruby? — petermichaux@... 2006/02/18

Thanks for the reply. From that QTRuby link "to create cross-platform

[#180373] Re: Desktop apps written in Ruby? — tsumeruby@... 2006/02/18

On Saturday 18 February 2006 01:08 pm, petermichaux@yahoo.com wrote:

[#180375] Re: Desktop apps written in Ruby? — Scott Weeks <weeksie@...> 2006/02/18

Why not just build the front end of the app in a windows language

[#180378] Re: Desktop apps written in Ruby? — tsumeruby@... 2006/02/18

On Saturday 18 February 2006 02:21 pm, Scott Weeks wrote:

[#180430] best way to use (exploit) mailing list. — John Maclean <info@...>

hey Chaps,

10 messages 2006/02/18

[#180487] maximum number of module methods? — Suraj Kurapati <skurapat@...>

-----BEGIN PGP SIGNED MESSAGE-----

12 messages 2006/02/18

[#180506] lazy.rb 0.9.5 -- transparent futures! — MenTaLguY <mental@...>

I'd like to announce a new version of lazy.rb -- this one offering

43 messages 2006/02/19
[#180853] Re: [ANN] lazy.rb 0.9.5 -- transparent futures! — Andrew Johnson <ajohnson@...> 2006/02/21

On Sun, 19 Feb 2006 10:07:12 +0900, MenTaLguY <mental@rydia.net> wrote:

[#180945] Re: [ANN] lazy.rb 0.9.5 -- transparent futures! — MenTaLguY <mental@...> 2006/02/21

On Tue, 2006-02-21 at 17:33 +0900, Andrew Johnson wrote:

[#180993] Re: lazy.rb 0.9.5 -- transparent futures! — Jim Weirich <jim@...> 2006/02/21

MenTaLguY wrote:

[#180997] Re: lazy.rb 0.9.5 -- transparent futures! — MenTaLguY <mental@...> 2006/02/21

On Wed, 2006-02-22 at 06:49 +0900, Jim Weirich wrote:

[#181023] Re: lazy.rb 0.9.5 -- transparent futures! — Jim Weirich <jim@...> 2006/02/22

MenTaLguY wrote:

[#180698] How can I search value from xml — "Artit Satanakulpanich" <rubybox@...>

How can i search value from xml file such as I want to find from *pubdate *=

15 messages 2006/02/20

[#180709] dirty ranges — dvandeun@... (Dirk van Deun)

I'm a new Ruby user (currently at page 68 of Programming Ruby !) and

12 messages 2006/02/20

[#180811] ANN: Second drop of RubyCLR bridge — "John Lam" <drjflam@...>

This is a much more complete drop of the bridge:

10 messages 2006/02/21

[#180889] Blocks / Closures — Picklegnome <picklegnome@...>

I've just been looking into Ruby in the last few days, and I must say it

14 messages 2006/02/21

[#181027] rubynuby - client side Ruby? — Jeff Pritchard <jp@...>

I would like to be able to do client-side scripting things that in the

19 messages 2006/02/22

[#181181] Mr. Guid 0.2 (Cross-platform Ruby GUI Debugger) — "mitchell" <ffsnoopy@...>

Mr. Guid 0.2 is a milestone release because it can now be run on both

22 messages 2006/02/23

[#181210] compiling c program using rb_eval_string() — hongseok.yoon@...

I tried to call rb_eval_string(), so I wrote simple C code.

6 messages 2006/02/23
[#181213] Re: compiling c program using rb_eval_string() — "Gyoung-Yoon Noh" <nohmad@...> 2006/02/23

On 2/23/06, hongseok.yoon@gmail.com <hongseok.yoon@gmail.com> wrote:> I tried to call rb_eval_string(), so I wrote simple C code.>> #include "/home/xopht/lib/1.8/i686-linux/ruby.h">> int main()> {> rb_eval_string( "puts" );> return 0;> }>> I compiled it and get bellow result.>> [xopht@odin ruby]$ g++ -o test test.cc -lruby-static -L/home/xopht/lib/> /home/xopht/lib//libruby-static.a(string.o)(.text+0x319a): In function> `rb_str_crypt':> /home/xopht/ruby/ruby-1.8.4/string.c:4360: undefined reference to> `crypt'> /home/xopht/lib//libruby-static.a(dln.o)(.text+0x9f): In function> `dln_load':> /home/xopht/ruby/ruby-1.8.4/dln.c:1351: undefined reference to `dlopen'> /home/xopht/lib//libruby-static.a(dln.o)(.text+0xb6):/home/xopht/ruby/ruby-1.8.4/dln.c:1356:> undefined reference to `dlsym'> /home/xopht/lib//libruby-static.a(dln.o)(.text+0x12b):/home/xopht/ruby/ruby-1.8.4/dln.c:1359:> undefined reference to `dlclose'> /home/xopht/lib//libruby-static.a(dln.o)(.text+0x5): In function> `dln_strerror':> /home/xopht/ruby/ruby-1.8.4/dln.c:1193: undefined reference to> `dlerror'> collect2: ld returned 1 exit status> [xopht@odin ruby]$>> what's wrong?>>>

[#181215] Re: compiling c program using rb_eval_string() — "Gyoung-Yoon Noh" <nohmad@...> 2006/02/23

On 2/23/06, Gyoung-Yoon Noh <nohmad@gmail.com> wrote:> On 2/23/06, hongseok.yoon@gmail.com <hongseok.yoon@gmail.com> wrote:> > I tried to call rb_eval_string(), so I wrote simple C code.> >> > #include "/home/xopht/lib/1.8/i686-linux/ruby.h"> >> > int main()> > {> > rb_eval_string( "puts" );> > return 0;> > }> >> > I compiled it and get bellow result.> >> > [xopht@odin ruby]$ g++ -o test test.cc -lruby-static -L/home/xopht/lib/> > /home/xopht/lib//libruby-static.a(string.o)(.text+0x319a): In function> > `rb_str_crypt':> > /home/xopht/ruby/ruby-1.8.4/string.c:4360: undefined reference to> > `crypt'> > /home/xopht/lib//libruby-static.a(dln.o)(.text+0x9f): In function> > `dln_load':> > /home/xopht/ruby/ruby-1.8.4/dln.c:1351: undefined reference to `dlopen'> > /home/xopht/lib//libruby-static.a(dln.o)(.text+0xb6):/home/xopht/ruby/ruby-1.8.4/dln.c:1356:> > undefined reference to `dlsym'> > /home/xopht/lib//libruby-static.a(dln.o)(.text+0x12b):/home/xopht/ruby/ruby-1.8.4/dln.c:1359:> > undefined reference to `dlclose'> > /home/xopht/lib//libruby-static.a(dln.o)(.text+0x5): In function> > `dln_strerror':> > /home/xopht/ruby/ruby-1.8.4/dln.c:1193: undefined reference to> > `dlerror'> > collect2: ld returned 1 exit status> > [xopht@odin ruby]$> >> > what's wrong?> >> >> >>> rb_string_eval() needs to be initialized properly.> Check this,> http://phrogz.net/ProgrammingRuby/ext_ruby.html#extendingruby> http://www.rubygarden.org/ruby?EmbedRuby>> --> http://nohmad.sub-port.net>

[#181224] Ruby as First Language — "woodyee" <wood_yee12@...>

Hi! I'm interested in getting opinions on Ruby as a first language. For

55 messages 2006/02/23
[#181479] Re: Ruby as First Language — "Timothy Goddard" <interfecus@...> 2006/02/24

My order was Quick BASIC, then C++, PHP, then Ruby. I found the

[#181520] Re: Ruby as First Language — Gregory Seidman <gsslist+ruby@...> 2006/02/25

On Sat, Feb 25, 2006 at 08:13:34AM +0900, Timothy Goddard wrote:

[#181526] Re: Ruby as First Language — "Chris Pine" <chris@...> 2006/02/25

On 2/25/06, Gregory Seidman <gsslist+ruby@anthropohedron.net> wrote:> 1) Logo as a preteen, or AWK and/or Bourne shell scripting at any age> 2) C (second procedural language)> 3) Ruby, Python, Java, or C# (first OOP language)

[#181261] Creating Ruby Classes from XSD? — "Justin Bailey" <jgbailey@...>

.NET ships with a tool that will generate classes directly from an XML

15 messages 2006/02/23

[#181291] LibXML-Ruby 0.3.6 — Ross Bamford <rossrt@...>

LibXML-Ruby 0.3.6 is now available from Rubyforge. LibXML-Ruby is (as

29 messages 2006/02/23

[#181315] Huge performance gap — Alexis Reigel <mail@...>

Hi all

79 messages 2006/02/23
[#181318] Re: Huge performance gap — "E. Saynatkari" <none@...> 2006/02/23

Alexis Reigel wrote:

[#199810] Re: Huge performance gap — Reggie Mr <buppcpp@...> 2006/07/01

Here is a simple graph of performance by different platforms.

[#199814] Re: Huge performance gap — "Austin Ziegler" <halostatue@...> 2006/07/01

On 7/1/06, Reggie Mr <buppcpp@yahoo.com> wrote:

[#199841] Re: Huge performance gap — "M. Edward (Ed) Borasky" <znmeb@...> 2006/07/01

Austin Ziegler wrote:

[#199864] Re: Huge performance gap — "Robert Klemme" <shortcutter@...> 2006/07/01

2006/7/1, M. Edward (Ed) Borasky <znmeb@cesmail.net>:

[#199885] Re: Huge performance gap — Reggie Mr <buppcpp@...> 2006/07/02

Austin Ziegler wrote:

[#199889] Re: Huge performance gap — Daniel DeLorme <dan-ml@...42.com> 2006/07/02

Reggie Mr wrote:

[#199890] Re: Huge performance gap — "Francis Cianfrocca" <garbagecat10@...> 2006/07/02

>

[#199915] Ruby and Rails performance profiling? — Robert Mela <rmela@...> 2006/07/02

What tools exist for profiling Ruby?

[#199916] Re: Ruby and Rails performance profiling? — "Francis Cianfrocca" <garbagecat10@...> 2006/07/02

Ruby has a built-in profiler. Fair enough, let's run it, it would be

[#199931] Re: Ruby and Rails performance profiling? — "M. Edward (Ed) Borasky" <znmeb@...> 2006/07/02

Francis Cianfrocca wrote:

[#181316] Fwd: Launching Ruby scripts and the future of MVM — "Charles O Nutter" <headius@...>

I tossed this message off to the Ruby-core list about a month ago, and

11 messages 2006/02/23
[#181325] Re: Launching Ruby scripts and the future of MVM — gwtmp01@... 2006/02/23

[#181343] Re: Launching Ruby scripts and the future of MVM — Logan Capaldo <logancapaldo@...> 2006/02/23

[#181377] Re: Launching Ruby scripts and the future of MVM — gwtmp01@... 2006/02/24

[#181379] Re: Launching Ruby scripts and the future of MVM — "Austin Ziegler" <halostatue@...> 2006/02/24

On 2/23/06, gwtmp01@mac.com <gwtmp01@mac.com> wrote:> On Feb 23, 2006, at 6:20 PM, Logan Capaldo wrote:>> On Feb 23, 2006, at 5:42 PM, gwtmp01@mac.com wrote:>>> On Feb 23, 2006, at 5:05 PM, Charles O Nutter wrote:>>>> I tossed this message off to the Ruby-core list about a month ago,>>>> and sent a follow-up email today. The basic idea is that if there>>>> were a Kernel#run_script method or similar, all Ruby apps that want>>>> to launch external scripts could do so in a platform and>>>> implementation-independent way.>>> In what way is what you are proposing different from Kernel#system?>> system(x) # x is arbitrary shell command>> run_script(x) # x is guaranteed to be a script written in ruby>>>> This means for instance, that run_script could get away with not>> forking a new process, but rather just a new ruby VM assuming that>> the ruby implementation had that capability> You already have coroutines, threads, fork/exec, system, and load/> require all of which give you different ways to manage multiple> threads of control and/or interpret external ruby code.

[#181420] Current Temperature (#68) — Ruby Quiz <james@...>

The three rules of Ruby Quiz:

25 messages 2006/02/24

[#181542] FasterCSV 0.1.6 -- With Header Support! — James Edward Gray II <james@...>

FasterCSV 0.1.6 Released

25 messages 2006/02/26
[#181543] Re: [ANN] FasterCSV 0.1.6 -- With Header Support! — "Gregory Brown" <gregory.t.brown@...> 2006/02/26

On 2/25/06, James Edward Gray II <james@grayproductions.net> wrote:

[#181705] Re: [ANN] FasterCSV 0.1.6 -- With Header Support! — James Edward Gray II <james@...> 2006/02/27

On Feb 25, 2006, at 7:22 PM, Gregory Brown wrote:

[#181667] Ruby Whitespace Semantics — Almann Goo <almann.goo@...>

Can someone please explain the semantics behind the following:

21 messages 2006/02/27

[#181690] string contains one of these??? — mikkel <mikkel@...>

Imagine,

17 messages 2006/02/27

[#181710] Dynamic stuff and books — Mc Osten <riko@...>

I started using ruby a couple of weeks ago and it's time to make a couple

14 messages 2006/02/27

[#181774] :-( — "Joe Van Dyk" <joevandyk@...>

Someone needs to make a "C++ for Ruby programmers" book. I'm getting

17 messages 2006/02/28

[#181812] Subclassing Struct.new — "Minkoo Seo" <minkoo.seo@...>

Hi group.

37 messages 2006/02/28
[#181814] Re: Subclassing Struct.new — "chiaro scuro" <kiaroskuro@...> 2006/02/28

On 2/28/06, Minkoo Seo <minkoo.seo@gmail.com> wrote:

[#181816] Re: Subclassing Struct.new — "Minkoo Seo" <minkoo.seo@...> 2006/02/28

It works! Thank you.

[#181819] Re: Subclassing Struct.new — "chiaro scuro" <kiaroskuro@...> 2006/02/28

On 2/28/06, Minkoo Seo <minkoo.seo@gmail.com> wrote:

[#181858] Re: Subclassing Struct.new — mental@... 2006/02/28

Quoting chiaro scuro <kiaroskuro@gmail.com>:

[#181862] Re: Subclassing Struct.new — "chiaro scuro" <kiaroskuro@...> 2006/02/28

On 2/28/06, mental@rydia.net <mental@rydia.net> wrote:

[#181885] rcov 0.2.0 - code coverage tool for Ruby — Mauricio Fernandez <mfp@...>

Source code, additional information, screenshots... available at

18 messages 2006/02/28

Re: Classes and OO design - help

From: David Vallner <david@...>
Date: 2006-02-21 02:27:07 UTC
List: ruby-talk #180818
Dňa Pondelok 20 Február 2006 10:48 Tony Mobily napísal:
> Hi David,
>
> I am not entirely sure about the list's etiquette. I hope it's OK to
> reply to you _and_ to the list (I imagine somebody in the future
> might be very interested in this discussion!)
>

Not particularly, although not really necessary. I'm enough of an attention 
whore to see if I've been replied on the list ;)

> OK. Is there a way of "forcing" the deallocation of an object?
>

Not really on the low level, short of starting the garbage collector. You'd 
call the deletion method explicitly.

> > 	def full_path
> > 		# insert that string addition thingy I'm too cheap to copy / paste
> > 	end
>
> Oh... OK. I was thinking about performance. This way, Ruby has to
> recalculate the string all the time.
> However, I can see that this should be the way to go...
>

Well, I doubt it's a killer in this case, but indeed probably a waste of CPU 
speed doing the same over and over.

You could cache the result of the path generation in the instance variable and 
lazily initialize it in the accessor, as you've done in the other getters. 
This should work:

	def full_path
		@full_path ||= parts + of + full + path
	end

Or plain keep this bit in the initializer as it was, the value is bound to be 
used anyway. Keeping the path generation bit where it's used seems a taaad 
bit cleaner to me.

> > The above would change to something like with what I have in mind:
> >
> > 	# Presuming the record exists.
> > 	sub = Subscriber.load("merc2@mobily.com")
> > 	puts sub.email
> > 	puts sub.premium?
> > 	puts sub.moderator?
> > 	puts "OK:"
> > 	puts sub.name = "BLAH!!!"
> > 	puts sub.name
> > 	sub.save # To put the changes to disk.
>
> For a number of reasons, I took the approach that changing a variable
> also changes the file right away.
> One of the reasons is that I will _very_ often 1) Open a subscriber
> 2) Change a little piece of information 3) Close the subscriber. The
> sub.save method would have to be intelligent enough to work out
> what's changed... it's a little too messy. It's much easier this way.
>

Wouldn't call it messy. Either way works, depends on how you use the objects. 
If you're can handle the difference between creating new records and loading 
old ones cleanly, it's fine. 

I think ActiveRecord only requires explicit saves on newly created objects and 
makes modifications to existing records transparently as you intend.

> >> * I am thinking about a container class for this:
> >> SubscribersContainer. The class would implement the method each(), so
> >> that I can scan through the list of people stored (creating a
> >> Subscriber object for iteration). Is this a sane approach?
> >
> > Yes. This class could also store the data directory path and manage
> > the
> > lifecycle of Subscriber objects, reducing those to only data
> > retrieval /
> > caching.
>
> You mean with something like:
>
> sub_container=SubscribersContainer.new()

A particularly sick thing to do would be making SubscribersContainer a 
singleton and then delegate calls to the class object to the single instance. 
Not really useful though.

> sub_container['merc'].name="tony"
>
> ...?
> When the method [](email) is called, the object SubscribersContainer
> would need to create a new object (if necessary), or return the one
> already created at some point in the past. Is that right?
>

I'd still keep the creation and loading as separate operations to avoid 
clobbering some data by mistake when thinking you're making a new record. 
There are other ways to preventing that though, like providing a method to 
check whether a given record exists.

> I am not sure why you say that this class would need the data
> directory...!
>

Well, I thought of this class providing the created Subscriber with the full 
record path and the e-mail address when creating the object. That way, you'd 
keep the what's stored where bit out of the Subscriber class.

You could also determine / change the config file directory at runtime from a 
parameter to the application more intuitively 
(SubscriberContainer.new("/path/to/record/directory/") instead of hardcoding 
it or manipulating class variables), or even have several containers - even 
if this would probably be rarely useful.

Last, but not least, at least to me it makes more sense for the container to 
have the information where its contents are stored.

> Also, I wonder if accessing too many objects that way wouldn't
> clutter the collection too much (the "real" number of subscribers we
> have is about 14000. I KNOW we need a DB. We didn't expect quite so
> many. I am planning to switch to DB)
>

You wouldn't have to actually store the retrieved object in the container 
after creation / loading, just have the container do this work and dumb down 
the Subscriber storage to data transfer and mutation, those being ignorant to 
as much context as possible.

> >  If you wanted to go extreme, you could also separate the data
> > retrieval part
> > and keep subscribers only as dumb data structured, but I'd say it
> > would only
> > be deconstructing code for the sake of deconstruction, and more
> > confusing
> > than anything else in this case.
>
> I'll ask about this later...
> The question will include the fact that I would like to make this
> class "generic", so that in the future I can change it so that it
> connects to a DB rather than reading the file system. At this point,
> I am not sure what the right path is. Maybe create a subscribers
> class, and then create a SubscriberFileSystem subclass which needs to
> implement get_flag, set_flag, get_field, set_field...?
>

For a SQL DB, I'd just skip the whole issue, use an ORM library like Og, port 
the code using Subscriber to it and not care about this bit. Possibly the 
easiest way if you can do an "instantaneous" migration between the filesystem 
backend and the SQL one.

The very generic solution would be worth the effort if you had to use the two 
wildly differing backends simultaneously. In that case, I'd definately keep 
the "housekeeping" to a container class, have the Subscriber objects know 
what container they belong in, and have them call on the container to sasve 
changes to them to disc. This would also possibly let you relocate objects 
between containers if that was of any use at all. You'd probably want to 
store which field(s) was changed to avoid unnecessary file access with this 
approach.

> > I'd say read through the Gang of Four and Refactoring,
>
> Woops... I've lost you here. Are you talking about one specific book?
> Or two books?

Well, THE Refactoring book *cackle*. But Dave Cantrell already answered this 
perfectly. Gang of Four is a nickname of the four authors of the book. Not 
quite up-to-date as far as the patterns mentioned are concerned - there are 
already droves more that have been invented since. But I like the case study 
bit as an explanation that shows an example of quite a few of those applied 
in a single program.

> Well... here is the latest version of my class.
> It would be fantastic if you could have a quick look at it, and let
> me know if I actually got it right design-wise.
> I haven't actually tested it properly - I am more interested in the
> big picture for now...
>
> THANKS AGAIN!
>
> #!/usr/local/bin/ruby -w
>
> class Subscriber
>
>          # Set the config file.
>          #
>          begin
>                  @@config_data_dir=IO.read("#{ENV['HOME']}/.subs/
> data_dir")
>                  @@config_data_dir.chomp!
>          rescue SystemCallError
>                  STDERR.puts("WARNING! Can't find the config file!");
>                  @@config_data_dir=""
>          end
>

Very minor quibble: I don't quite like too much code executed inline in class 
definitions, and would probably move this along with all other application 
initialization into one place. Quite possibly a matter of taste more than 
anything else though - since the code doesn't have side-effects, it's not 
likely to cause any obscure bug due to initialization timing.

>          def initialize()
>                  @email=nil
>          end
>
>          def first_letter
>                  return nil if ! @email
>                  @email[0, 1].upcase if @email
>          end
>
>          def full_path
>                  return nil if ! @email
>                  @@config_data_dir+"/current/"+self.first_letter
> +"/"+@email+"/"
>          end
>
>          # This just checks that the directory actually
>          # exists. It creates a "link"
>          #
>          def link_to(email_param)
>
>                  # Hang on: if the file doesn't exist, undo everything
>                  #
>                  @email=email_param
>                  if ! File.exist?(self.full_path)
>                          @email=nil
>                          return false
>                  end
>
>                  @premium_flag=nil
>                  @moderator_flag=nil
>                  @unconfirmed_flag=nil
>
>                  @country=nil
>                  @creation_date=nil
>                  @name=nil
>                  @password=nil
>                  @postcode=nil
>                  @premium_expiry_date=nil
>                  @questionnaire_res=nil
>                  @subscriber_code=nil
>                  @subscriber_comments=nil
>

This shouldn't be necessary. Reading uninitialized instance variables results 
in a nil by default.

>                  true
>
>          end
>
>          attr_reader :email
>
>          # Accessors for the subscriber's information
>
>          #
>          # FLAGS:
>          #
>
>          # premium_flag
>          #
>          def premium_flag?
>                  @premium_flag ||= get_flag(:premium_flag)
>          end
>          def premium_flag=
>                  @premium_flag = set_flag(:premium_flag,value)
>          end
>
>          # moderator_flag
>          #
>          def moderator_flag?
>                  @moderator_flag ||= get_flag(:moderator_flag)
>          end
>          def moderator_flag=(value)
>                  @moderator_flag = set_flag(:moderator_flag,value)
>          end
>
>          # unconfirmed_flag
>          #
>          def unconfirmed_flag?
>                  @unconfirmed_flag ||= get_flag(:unconfirmed_flag)
>          end
>          def unconfirmed_flag=(value)
>                  @unconfirmed_flag=set_flag(:unconfirmed_flag,value)
>          end
>
>          #
>          # ATTRIBUTES
>          #
>
>          def country
>                  @country ||= get_field(:country)
>          end
>          def country=(value)
>                  @country = set_field(:country,value)
>          end
>
>          def creation_date
>                  @creation_date ||= get_field(:creation_date)
>          end
>          def creation_date=(value)
>                  @creation_date = set_field(:creation_date,value)
>          end
>
>          def name
>                  @name ||= get_field(:name)
>          end
>          def name=(value)
>                  @name = set_field(:name,value)
>          end
>
>          def password
>                  @password ||= get_field(:password)
>          end
>          def password=(value)
>                  @password = set_field(:password,value)
>          end
>
>          def postcode
>                  @postcode ||= get_field(:postcode)
>          end
>          def postcode=(value)
>                  @postcode = set_field(:postcode,value)
>          end
>
>          def questionnaire_res
>                  @questionnaire_res ||= get_field(:questionnaire_res)
>          end
>          def questionnaire_res=(value)
>                  @questionnaire_res = set_field
> (:questionnaire_res,value)
>          end
>
>          def subscriber_code
>                  @subscriber_code ||= get_field(:subscriber_code)
>          end
>          def subscriber_code=(value)
>                  @subscriber_code = set_field(:subscriber_code,value)
>          end
>
>          def subscriber_comments
>                  @subscriber_comments ||= get_field
> (:subscriber_comments)
>          end
>          def subscriber_comments=(value)
>                  @subscriber_comments = set_field
> (:subscriber_comments,value)
>          end
>
>          private
>
>          def get_flag(flag)
>                  return nil if ! @email
>                  File.exist?(self.full_path+flag.to_s)
>          end
>
>          def get_field(field)
>
>                  return nil if ! @email
>
>                  # Reads the file from the file system; returns
>                  # nil if the file can't be opened
>                  #
>                  begin
>                          IO::read(self.full_path+field.to_s)
>                  rescue SystemCallError
>                          nil
>                  end
>
>          end
>
>
>          def set_field(field,value)
>
>                  return nil if ! @email
>
>                  # Open the file
>                  #
>                  begin
>                          ios=File::open(self.full_path+field.to_s,"w")
>                  rescue SystemCallError
>                          return nil
>                  end
>

You might not want to ignore the error here. It probably means something 
really, really unexpected happened - the only thing short of a kernel-ish 
problem, like a file system faliure or the file handle table filling up that 
could call an error in this I can imagine is that a file of the same name 
without the necessary write permissions exists, and that seems unlikely for 
this application. Either way, a SystemCallError sounds like a showstopper for 
me.

>                  # Set the value to nil. This is to reflect the
>                  # "real" state of the variable (the file has just been
>                  # cleared up by the previous call)
>                  #
>                  begin
>                          ios.print(value)
>                  rescue SystemCallError
>                          ios.close
>                          return nil
>                  end
>

I'd merge this code block with the previous one, and possibly handle the 
exception somewhere else, reporting it to the user as a severe failure, and 
logging it. You could also use the block form of File::open here.

You'd end up cluttering the code with checks for nil all the time, which is 
only proper if you expect the issue to appear during more-or-less regular 
operation; e.g. for calls where a failure isn't abnormal.

>                  # OK, it worked: assign the new value
>                  #
>                  ios.close
>                  value
>
>          end
>
>          def set_flag(flag,value)
>
>                  return nil if ! @email
>
>                  if(value)
>                          begin
>                                  File.open(self.full_path+flag.to_s,"w")
>                          rescue SystemCallError
>                                  return nil
>                          end
>                          return true
>                  else
>                          begin
>                                  File.delete(self.full_path+fiag.to_s)
>                          rescue SystemCallError
>                                  return nil
>                          end
>                          return false
>                  end
>          end
>

Same here as in the previous method, just let the SystemCallError pass up on 
the stack -it's probably not possible to gracefully recover from it.

> end
>
> a_subscriber=Subscriber.new()
> p a_subscriber.email
> p a_subscriber.link_to("merc2@mobily.com")
> p a_subscriber.email
> p a_subscriber.premium_flag?
> p a_subscriber.moderator_flag?
> puts "OK:"
> p a_subscriber.name="ooppp!!!"
> p a_subscriber.name
>
>
> Merc.

David Vallner


In This Thread