Skip to content

Instantly share code, notes, and snippets.

@woods
Created October 7, 2015 21:13
Show Gist options
  • Save woods/fc7b4db9747d28b58a0e to your computer and use it in GitHub Desktop.
Save woods/fc7b4db9747d28b58a0e to your computer and use it in GitHub Desktop.
We don't need no stinkin' databases!
#!/usr/bin/env ruby
require 'yaml'
puts "How many sections?"
number_of_sections = Integer(gets)
data = YAML.load(DATA)
data['start'] = data['end'] + 1
data['end'] += number_of_sections
File.open($0, 'r+') do |f|
loop do
break if f.gets =~ /^__END__/
end
f.write(data.to_yaml)
end
__END__
start: 124
end: 127
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment