Skip to content

Instantly share code, notes, and snippets.

@cwgem
Created July 28, 2011 11:33
Show Gist options
  • Select an option

  • Save cwgem/1111417 to your computer and use it in GitHub Desktop.

Select an option

Save cwgem/1111417 to your computer and use it in GitHub Desktop.
不思議なDATA
require 'yaml'
state = DATA.read
state = (state.empty?) ? [] : YAML::load(state)
state << 1
puts state.inspect
code = File.new(__FILE__).readlines
code = code[0..(code.find_index{ |x| /\A__END__\s*\z/ =~ x })].join("") << "\n" << YAML::dump(state)
File.new(__FILE__, 'w').write(code)
__END__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment