I am in the middle of writing a wrapper to FORTRAN programs using
Ruby.  It going great so far.  The problem that I need this groups
help to solve follows:

For the purposes of a reference, a log and to allow continuation of
the script, I have created a function that writes inquired values to a
file, as follows:

def savevaribles
  fs = File.new("./savedvaribles.rb","w")
  # Saved variables from harmprocessing.rb
  fs.puts "# Saved variables from harmprocessing.rb"
  fs.puts "$year = #{$year}"
  fs.puts "$gonl = #{$gonl}"
  fs.puts "$tm = #{$tm}"
  fs.puts "$timezone = #{$timezone}"
  fs.close
end

Which creates a file that I can "load" with all my variables.
# Saved variables from harmprocessing.rb
$gonl = 149.98435
$tm = 135
$timezone = -9

The list is much more extensive than this and many of the values are
not set until later in the analysis.  If the value is not set or if it
is "nil" the commands #{$value} is blank, which is fine except,
$value1 =
$value2 = 42
Upon reading the file, the value of $value1 is set to 42 also, which
confuses further analyses.
So I am trying to figure out a cleaver means to check if each value
exists or nil then 'puts "nil"' so there are no more blanks.
I can do this the brute force method, with if/then statements
everywhere, but I was wondering if there is a Ruby way to accomplish
this.

I appreciate your help.
Chris