Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: Looking for help implementing static variables
Joel VanderWerf
8/29/2007 8:59:00 PM
Harry Truax wrote:
> Hello,
>
> I am working on an application where we are trying to remember previous
> values from an execution of a Ruby program. Basically, we have a screen
> where a user can type an 'X' into either a 'Yes' or a 'No' box. We do not
> want them to type Xs into both boxes. So if the 'Yes' box has an X in it,
> and then the user types an 'X' into the 'No' box, we want to clear the 'Yes'
> box automatically. Our Ruby program runs each time the user tabs out of a
> field on the screen or presses the Enter key.
This isn't built into ruby, which is probably a good thing because there
are many different ways of doing it.
A typical solution will involve one of ruby's standard object
persistence mechanisms, either Marshal (not humanly readable, but
efficient) or YAML (humanly readable, and also readable by Perl, Python,
etc.).
There's also the question of where to store this file. On unix/linux,
you might want to use a "dot" file in the user's home dir, or in
ENV["HOME"]. On windows, there is a different standard for selecting the
location (ENV['APPDATA'], for example)).
I wrote a small library that does this using YAML. See:
http://redshift.sourceforge.net/p...
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: Looking for help implementing static variables
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password