Skip to content

Instantly share code, notes, and snippets.

@bil-bas

bil-bas/shift.rb Secret

Forked from akahn/shift.rb
Created January 12, 2012 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bil-bas/278b563aa473c5c26994 to your computer and use it in GitHub Desktop.
Save bil-bas/278b563aa473c5c26994 to your computer and use it in GitHub Desktop.
# "Shift" the first line off of the file
class File
def self.shift(file)
File.open(file) do |input|
first_line = input.gets
File.open(file, 'w') do |output|
input.each_line {|line| output.puts line }
end
first_line
end
end
end
puts File.shift("shift_file.txt")
puts
puts File.read("shift_file.txt")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment