title: Updating a YAML file in Ruby
body: <p>My class is:</p>
  
  <pre><code>class Mycfg
      @@options = {}
  
      def init
          @@options = YAML.load_file(Dir.pwd + PATH)
      end
  
      def set(key, val)
          @@options[key] = val
      end
  
      def get(key)
          @@options[key]
      end
  
      def save
      end
  end
  </code></pre>
  
  <p>Using this class:</p>
  
  <pre><code>oj = Mycfg.new
  oj.init
  
  if oj.get 'name' == 'tom'
     oj.set 'changed', Data.now
  end
  
  oj.save
  </code></pre>
  
  <p>YAML file:</p>
  
  <pre><code>name : tom
  pawd : 123456
  version : 0.0.1
  created : 2011-10-24
  changed : 2011-10-24
  </code></pre>
  
  <p>How to I finish the method <code>save</code> to update the YAML file if something has changed?</p>