On Wed, Mar 9, 2011 at 9:55 PM, Joyce Lima <jojosl / hotmail.com> wrote:
> I'm doing one work school, sorry don't write english very good, I'm
> brasilian. I want delete only one line of File.
> I have two files and have to handle them according
> with data received by users in case some have
> Students enrolled in the following way name! id: registration.
> The user enters the id of the student, I have to search
> the file and delete the row for that id. Since there
> I found nothing specific files I'm using
> delete_if, look at the code, I'll attach it.

(If I understand, we are looking at opcao == 2 (Excluir Aluno)?)

Here is a small example of one way to copy from one array to another:

  input = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
  output = []

  input.each do |n|
    if n == 4
      # skip it
    else
      output << n
    end
  end

  p output #=> [1, 2, 3, 5, 6, 7, 8, 9, 10]

Working with files, I might do something like:
* Create a temporary output file
* Write to the output file while reading from the original input
* When finished, move temporary file over the original